public void FillFees_should_throw_exeption_if_any_argument_is_null() { var feesViewModel = new FeesViewModel(); List<AppraiserFee> fees = new List<AppraiserFee>(); var refManager = Substitute.For<IReferenceManagement>(); var feeManager = new FeeManager(refManager); feeManager.Invoking(fm => fm.FillFees(null, feesViewModel)).ShouldThrow<ArgumentNullException>().And.ParamName.Should().Contain("fees"); feeManager.Invoking(fm => fm.FillFees(fees, null)).ShouldThrow<ArgumentNullException>().And.ParamName.Should().Contain("fees view model"); }
public void FillFees_should_throw_exeption_if_passed_invalid_product_type() { var refManager = Substitute.For<IReferenceManagement>(); refManager.GetProductNameById(1).Returns("name1"); var feeManager = new FeeManager(refManager); List<AppraiserFee> model = new List<AppraiserFee>(); var feesViewModel = new FeesViewModel(); feesViewModel.FeesItems.Add(new FeeItemViewModel() { Id = "2", ProductType = 200, Fee = 20 }); feeManager.Invoking(m => m.FillFees(model, feesViewModel)).ShouldThrow<ArgumentException>().And.Message.Should().Contain("product id"); ; }
public void GetFeesViewModel_should_fill_in_properties_correctly() { var refManager = Substitute.For<IReferenceManagement>(); var feeManager = new FeeManager(refManager); AppraiserFee[] fees = { new AppraiserFee(){Id = 1, ProductId = 1, Amount = 1.1 }, new AppraiserFee(){Id = 2, ProductId = 2, Amount = 10.1 } }; var actual = feeManager.GetFeesViewModel(fees); actual.FeesItems.Count.Should().BeGreaterOrEqualTo(fees.Count()).And.BeLessOrEqualTo(fees.Count()); for (int i = 0; i < actual.FeesItems.Count; i++) { string productName = refManager.GetProductNameById(actual.FeesItems[i].ProductType); actual.FeesItems[i].ProductName.Should().BeEquivalentTo(productName); actual.FeesItems[i].Id.Should().BeEquivalentTo(fees[i].Id.ToString()); actual.FeesItems[i].Fee.Should().BeGreaterOrEqualTo(fees[i].Amount).And.BeLessOrEqualTo(fees[i].Amount); } }
public void FillFees_should_fill_in_properties_correctly() { var refManager = Substitute.For<IReferenceManagement>(); refManager.GetProductNameById(3).Returns("name1"); refManager.GetProductNameById(4).Returns("name2"); var feeManager = new FeeManager(refManager); List<AppraiserFee> actual = new List<AppraiserFee>(); actual.Add(new AppraiserFee(){Id = 1, ProductId = 1, Amount = 1.1 }); actual.Add(new AppraiserFee(){Id = 2, ProductId = 2, Amount = 10.1 }); var feesViewModel = new FeesViewModel(); feesViewModel.FeesItems.Add(new FeeItemViewModel() { Id = "2", ProductType = 3, Fee = 20 }); feesViewModel.FeesItems.Add(new FeeItemViewModel() { Id = Guid.NewGuid().ToString(), ProductType = 4, Fee = 200 }); feeManager.FillFees(actual, feesViewModel); for (int i = 0; i < actual.Count; i++) { actual[i].Id.ToString().Should().BeEquivalentTo(actual[i].Id == 0 ? "0" : feesViewModel.FeesItems[i].Id); actual[i].Amount.Should().BeGreaterOrEqualTo(feesViewModel.FeesItems[i].Fee.Value).And.BeLessOrEqualTo(feesViewModel.FeesItems[i].Fee.Value); actual[i].ProductId.Should().Be(feesViewModel.FeesItems[i].ProductType); } }
public void Constructor_test() { var refManager = Substitute.For<IReferenceManagement>(); var actual = new FeeManager(refManager); actual.Should().NotBeNull(); }