//// GET api/values/5 //public string Get(int id) //{ // return "value"; //} // POST api/values public void Post([FromBody] CreatePolicyCommand command) { var insurancePolicy = new InsurancePolicy(this.ServiceLocator); //Create the policy. This is the only way you can create a policy insurancePolicy.CreatePolicy(command); }
public void CreatePolicy_WithValidData_ShouldSucceed() { var policyNumber = Guid.NewGuid().ToString(); var serviceLocator = new ServiceLocatorProduction(); //New up the domain model. Everything is null, but it's ready to work var insurancePolicy = new InsurancePolicy(serviceLocator); //Create the policy. This is the only way you can create a policy insurancePolicy.CreatePolicy(new CreatePolicyCommand() { Coverage = new List <string>() { "CoverageA" }, PolicyNumber = policyNumber }); //Verify the domain model has been updated Assert.AreEqual(1, insurancePolicy.Coverage.Count, string.Format("Should only be 1 coverage but there were {0}", insurancePolicy.Coverage.Count)); //Reset the system so we can verify getting the object from the stream insurancePolicy = new InsurancePolicy(serviceLocator); insurancePolicy.GetPolicyByPolicyNumber(policyNumber); Assert.AreEqual(1, insurancePolicy.Coverage.Count, string.Format("Should only be 1 coverage but there were {0}", insurancePolicy.Coverage.Count)); //Add a coverage to the policy insurancePolicy.AddCoverageToPolicy(new AddCoverageCommand() { Coverage = "CoverageB" }); Assert.AreEqual(2, insurancePolicy.Coverage.Count, string.Format("Should 2 coverage but there were {0}", insurancePolicy.Coverage.Count)); //Verify that we actually added the coverage Assert.AreEqual(2, insurancePolicy.Coverage.Count, string.Format("Should 2 coverage but there were {0}", insurancePolicy.Coverage.Count)); //Reset the system so we can verify the coverage was added. insurancePolicy = new InsurancePolicy(serviceLocator); insurancePolicy.GetPolicyByPolicyNumber(policyNumber); Assert.AreEqual(2, insurancePolicy.Coverage.Count, string.Format("Should 2 coverage but there were {0}", insurancePolicy.Coverage.Count)); }