Building Quotation engine program

Answer Posted / perfdev

TravelInsuranceQuoteTests --> BusinessLayer -->QuoteEngineTests.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using TravelInsuranceQuote.DataLayer;
using TravelInsuranceQuote.BusinessLayer;

namespace TravelInsuranceQuoteTests.BusinessLayer
{
[TestFixture]
public class QuoteEngineTests
{
[Test]
public void QuoteEngine_CanCreateObject()
{
var quoteEngine = new QuoteEngine();
Assert.That(quoteEngine, Is.Not.Null);
Assert.That(quoteEngine, Is.TypeOf<QuoteEngine>());
}

[Test]
public void GetBasePremium_ValidSingleTripType_ReturnsPremium()
{
var quoteEngine = new QuoteEngine();

var premium = quoteEngine.GetBasePremium(TripType.Single);

Assert.That(premium, Is.EqualTo(20.00));
}

[Test]
public void GetBasePremium_ValidAnnualTripType_ReturnsPremium()
{
var quoteEngine = new QuoteEngine();

var premium = quoteEngine.GetBasePremium(TripType.Annual);

Assert.That(premium, Is.EqualTo(80.00));
}

[Test]
public void GetAgeRating_ValidAgeRange_ReturnsRating()
{
var quoteEngine = new QuoteEngine();

var rating = quoteEngine.GetAgeRating(50);

Assert.That(rating, Is.EqualTo(1.2));
}

[Test]
public void GetAgeRating_HighAgeRange_ReturnsZero()
{
var quoteEngine = new QuoteEngine();

var rating = quoteEngine.GetAgeRating(90);

Assert.That(rating, Is.EqualTo(0));
}

[Test]
public void GetSexRating_InputFemale_ReturnsRating()
{
var quoteEngine = new QuoteEngine();

var rating = quoteEngine.GetSexRating(Sex.Female);

Assert.That(rating, Is.EqualTo(0.9));
}

[Test]
public void GetDestinationRating_InputWorlwide_ReturnsRating()
{
var quoteEngine = new QuoteEngine();

var rating = quoteEngine.GetDestinationRating(Destination.Worldwide);

Assert.That(rating, Is.EqualTo(1.4));
}

[Test]
public void GetTravelPeriodRating_InputValidDays_ReturnsRating()
{
var quoteEngine = new QuoteEngine();

var rating = quoteEngine.GetTravelPeriodRating(10);

Assert.That(rating, Is.EqualTo(0.9));
}

[Test]
public void GetUpdatedPremium_InputPremiumAndRate_ReturnsUpdatedPremiumAndDifference()
{
var quoteEngine = new QuoteEngine();

var updatedPremium = quoteEngine.GetUpdatedPremium(10.00, 2.0);

Assert.That(updatedPremium[0], Is.EqualTo(20.00));
Assert.That(updatedPremium[1], Is.EqualTo(10.00));
}

[Test]
public void GetPremium_InputCustomer_ReturnsCustomerPremium()
{
var quoteEngine = new QuoteEngine();
var customer = new Customer {
TripType = TripType.Single,
Age = 20,
Sex = Sex.Male,
Destination = Destination.Europe,
TravelPeriod = 1
};
string reason;
var customerPremium = quoteEngine.GetPremium(customer, out reason);

Assert.That(customerPremium.Base, Is.EqualTo(20.00));
Assert.That(customerPremium.Age[0], Is.EqualTo(20.00));
Assert.That(customerPremium.Sex[1], Is.EqualTo(4.00));
Assert.That(customerPremium.Destination[0], Is.EqualTo(24.00));
Assert.That(customerPremium.TravelPeriod[1], Is.EqualTo(-12.00));
Assert.That(customerPremium.Tax[0], Is.EqualTo(12.60));
Assert.That(customerPremium.Total, Is.EqualTo(12.60));
Assert.That(reason, Is.EqualTo(string.Empty));
}
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the difference between read the data from table and infotype

2041


what is session state?

1509


Diffrence between 2.0,3.0,3.5,4.0. versions of .net?

2758


What is test execution and when will we start execution please send me one example for this question

1417


hi all, i need ur help in preparing a sql which performs scd2, i mean i have a scd2 mapping i need a sql which can give me same result as scd2 mapping, SRC table: cust_no, loc 01 abc 02 xyz TGT table: pm_ky cust_no loc current_flag 1 01 abc Y 2 02 xyz Y cust 1 has changed his loc to xyz then it loads into TGT table as below, pm_ky cust_no loc current_flag 1 01 abc N 2 02 xyz Y 3 01 xyz Y i need sql to get the above result, hope got me question, Any suggestion will be appreciate.. thanks, Vinod

1633






When you deliver your C++ headers and C++ library of a class (what all can you change in the class so that application using your class does not need to recompile the code)

716


Write a program to reverse a number?

651


Find out the roles which gives access to all tables in SAP? Thanks in advance.

1552


Write a program to find factorial of a number using functions

1235


I'm new to ABAP. What is Module pool in SAP?

2117


what are the activities you enjoy most and How do you see these Developing in the Future with Reference to in your work life and in your personal life

1033


how to check single or double byte in struts

1547


5. Which of the following can you do with DB2 Express- C? Query databases with SQL Query databases with XML using XQuery and XPath Use SQL in Xquery and Xquery in SQL All of the above

2119


For a binary tree with n nodes, How many nodes are there which has got both a parent and a child?

3174


what is the difference between SCAN AND CHECK,LOKUP AND XFOOT? where we can use thease opcodes? Can any body tell me real time senariao with example?

2079