public void Mapper_WhenMappingPolicyTransaction_MapsAllValuesCorrectly() { // Arrange var mapper = new PolicyTransactionMapper(); var address = new AddressDto() { Line1 = "Line1", Line2 = "Line2", Town = "Town" }; var modelFrom = new PolicyTransaction() { PolicyId = "PolicyId" }; modelFrom.Addresses.Add(address); Models.Domain.IPolicyTransaction modelTo = Substitute.For <Models.Domain.IPolicyTransaction>(); modelTo.Addresses = new List <Address>(); // Act mapper.Map(modelFrom, modelTo); // Assert Assert.Equal("PolicyId", modelTo.PolicyId); Assert.Single(modelTo.Addresses); Assert.Collection(modelTo.Addresses, first => { Assert.Equal("Line1", first.Line1); Assert.Equal("Line2", first.Line2); Assert.Equal("Town", first.Town); }); }
public object Payment(PolicyTransaction objCustomerPayment) { try { SqlConnection con = new SqlConnection("Data Source=DESKTOP-SS8I9A6;Initial Catalog=happy;Integrated Security=True"); //string strcon = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); //SqlConnection con = new SqlConnection(strcon); SqlCommand cmd = new SqlCommand("spTransaction", con); cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.AddWithValue("@TransactionID", objCustomerPayment.TransactionID); cmd.Parameters.AddWithValue("@BankName", objCustomerPayment.BankName); cmd.Parameters.AddWithValue("@ChequeNumber", objCustomerPayment.ChequeNumber); cmd.Parameters.AddWithValue("@PolicyDetailID", objCustomerPayment.PolicyDetailID); cmd.Parameters.AddWithValue("@DateTimeStamp", objCustomerPayment.DateTimeStamp); con.Open(); int k = cmd.ExecuteNonQuery(); if (k != 0) { return("sucess"); } else { return("Fail"); } } catch (Exception Ex) { return(new Response { Status = "Error", Message = "Invalid Data." }); } }
public void Mapper_WhenMappingPolicyTransaction_MapsAllValuesCorrectly_Fluent() { // Arrange var mapper = new PolicyTransactionMapper(); var address = new AddressDto() { Line1 = "Line1", Line2 = "Line2", Line3 = "Line3", Town = "Town" }; var modelFrom = new PolicyTransaction() { PolicyId = "PolicyId" }; modelFrom.Addresses.Add(address); Models.Domain.IPolicyTransaction modelTo = Substitute.For <Models.Domain.IPolicyTransaction>(); modelTo.Addresses = new List <Address>(); // Act mapper.Map(modelFrom, modelTo); // Assert modelTo.Addresses.Should().SatisfyRespectively( first => { first.Line1.Should().Be("Line1"); first.Line2.Should().Be("Line2"); first.Line3.Should().BeNull(); first.Town.Should().Be("Town"); }); }