Esempio n. 1
0
        public void TestPutWithRequiredParametersNotSpecified()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim expectedClaim  = TestDataGenerator.GetTestClaim(newClaimNumber);

            // Create a new claim
            HttpResponseMessage response = ClaimsController.Post(expectedClaim);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, "A POST of a new claim should succeed.");

            // Prepare a claim "updater".
            MitchellClaim updater = new MitchellClaim();

            updater.ClaimantLastName = "NewLastName";

            updater.Vehicles = new List <VehicleDetails>();

            // We'll request a new vehicle to be added. However, this vehicle has required parameters that are not specified.
            updater.Vehicles.Add(new VehicleDetails()
            {
                Vin = TestDataGenerator.GenerateUniqueVinNumber(), Mileage = 100
            });

            // Update the claim.
            response = ClaimsController.Put(newClaimNumber, updater);
            Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode, "An update of a claim that would results in required fields that are not specified should fail with a specific status.");

            // Retrieved the claim we attempted to update and make sure it did not change.
            MitchellClaim retrievedClaim = ClaimsController.Get(newClaimNumber);

            Assert.AreEqual(expectedClaim, retrievedClaim, "The claim that was subject to a failed update should not have changed.");
        }
Esempio n. 2
0
        public void TestPutClaimWithEmptyVehicleList()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim expectedClaim  = TestDataGenerator.GetTestClaim(newClaimNumber);

            // Create a new claim
            HttpResponseMessage response = ClaimsController.Post(expectedClaim);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, "A POST of a new claim should succeed.");

            // Prepare a claim "updater".
            MitchellClaim updater = new MitchellClaim();

            updater.ClaimantLastName       = "NewLastName";
            expectedClaim.ClaimantLastName = updater.ClaimantLastName;

            updater.Vehicles = new List <VehicleDetails>();

            // Update the claim.
            response = ClaimsController.Put(newClaimNumber, updater);
            Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode, "An update request where the updater has an empty vehicle list is not legal.");

            // Retrieved the claim we attempted to update and make sure it did not change.
            MitchellClaim retrievedClaim = ClaimsController.Get(newClaimNumber);

            Assert.AreEqual(expectedClaim, retrievedClaim, "The claim that was subject to a failed update should not have changed.");
        }
Esempio n. 3
0
        public void TestPutClaimWithNoVehicleList()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim expectedClaim  = TestDataGenerator.GetTestClaim(newClaimNumber);

            // Create a new claim
            HttpResponseMessage response = ClaimsController.Post(expectedClaim);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, "A POST of a new claim should succeed.");

            // Prepare a claim "updater".
            MitchellClaim updater = new MitchellClaim();

            updater.ClaimantLastName       = "NewLastName";
            expectedClaim.ClaimantLastName = updater.ClaimantLastName;

            // Update the claim.
            response = ClaimsController.Put(newClaimNumber, updater);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "A PUT of an existing claim should succeed.");

            // Retrieved the updated claim and compare it with the expected value.
            MitchellClaim retrievedClaim = ClaimsController.Get(newClaimNumber);

            Assert.AreEqual(expectedClaim.Vehicles.Count, 2, "Defensive check - making sure that the expected claim was setup correctly.");
            Assert.AreEqual(expectedClaim, retrievedClaim, "The claim that was created, updated and retrieved should have the expected values.");
        }
Esempio n. 4
0
        public void TestPutClaimAndAddNewVehicle()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim expectedClaim  = TestDataGenerator.GetTestClaim(newClaimNumber);

            // Create a new claim
            HttpResponseMessage response = ClaimsController.Post(expectedClaim);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, "A POST of a new claim should succeed.");

            // Prepare a claim "updater".
            MitchellClaim updater = new MitchellClaim();

            updater.ClaimantLastName       = "NewLastName";
            expectedClaim.ClaimantLastName = updater.ClaimantLastName;

            // Note:  The updater will have to include both vehicles that are changed and those who are not changed.
            //        The vehicles that are not changed will only have the Vin field set.
            //        This system enables us to delete vehicles with the update request. The tread-off is that when we
            //        specify a list of vehicles then that list must include vehicles that are not changed.
            updater.Vehicles = new List <VehicleDetails>();

            updater.Vehicles.Add(new VehicleDetails()
            {
                Vin = expectedClaim.Vehicles[0].Vin
            });
            updater.Vehicles.Add(new VehicleDetails()
            {
                Vin = expectedClaim.Vehicles[1].Vin
            });

            // We'll request a new vehicle to be added. However, this vehicle has required parameters that are not specified.
            VehicleDetails newVehicle = new VehicleDetails()
            {
                Vin       = TestDataGenerator.GenerateUniqueVinNumber(),
                ModelYear = 2015,
                Mileage   = 200
            };

            updater.Vehicles.Add(newVehicle);
            expectedClaim.Vehicles.Add(newVehicle.DeepClone());

            // Update the claim.
            response = ClaimsController.Put(newClaimNumber, updater);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "A PUT of an existing claim should succeed.");

            // Retrieved the updated claim and compare it with the expected value.
            MitchellClaim retrievedClaim = ClaimsController.Get(newClaimNumber);

            Assert.AreEqual(expectedClaim.Vehicles.Count, 3, "Defensive check - making sure that the expected claim was setup correctly.");
            Assert.AreEqual(expectedClaim, retrievedClaim, "The claim that was created, updated and retrieved should have the expected values.");
        }
Esempio n. 5
0
        public void ClaimsController_Put()
        {
            Claim application = new Claim()
            {
                ClaimCode   = "VIEW_ONLY",
                ClaimId     = 1,
                Description = "View Only",
                Title       = "View Only Claim"
            };
            ClaimsController _controller = new ClaimsController(_mockService.Object, _logger.Object);
            var result = _controller.Put(application);

            Assert.IsNotNull(result);
        }
Esempio n. 6
0
        public void TestPutSimple()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim expectedClaim  = TestDataGenerator.GetTestClaim(newClaimNumber);

            // Create a new claim
            HttpResponseMessage response = ClaimsController.Post(expectedClaim);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, "A POST of a new claim should succeed.");

            // Prepare a claim "updater".
            MitchellClaim updater = new MitchellClaim();

            updater.ClaimantLastName       = "NewLastName";
            expectedClaim.ClaimantLastName = updater.ClaimantLastName;

            updater.LossDate       = expectedClaim.LossDate.Value.AddDays(1);
            expectedClaim.LossDate = updater.LossDate;

            // Note:  The updater will have to include both vehicles that are changed and those who are not changed.
            //        The vehicles that are not changed will only have the Vin field set.
            //        This system enables us to delete vehicles with the update request. The tread-off is that when we
            //        specify a list of vehicles then that list must include vehicles that are not changed.
            updater.Vehicles = new List <VehicleDetails>();

            updater.Vehicles.Add(new VehicleDetails()
            {
                Vin = expectedClaim.Vehicles[0].Vin
            });

            VehicleDetails sourceVehicle  = expectedClaim.Vehicles[1];
            VehicleDetails updaterVehicle = new VehicleDetails()
            {
                Vin     = sourceVehicle.Vin,
                Mileage = sourceVehicle.Mileage + 100
            };

            updater.Vehicles.Add(updaterVehicle);
            sourceVehicle.Mileage = updaterVehicle.Mileage;

            // Update the claim.
            response = ClaimsController.Put(newClaimNumber, updater);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "A PUT of an existing claim should succeed.");

            // Retrieved the updated claim and compare it with the expected value.
            MitchellClaim retrievedClaim = ClaimsController.Get(newClaimNumber);

            Assert.AreEqual(expectedClaim, retrievedClaim, "The claim that was created, updated and retrieved should have the expected values.");
        }
Esempio n. 7
0
        //[TestMethod]
        async public Task UpdateClaim()
        {
            var claim = new MitchellClaimType();

            claim.ClaimNumber       = "22c9c23bac142856018ce14a26b6c2991";
            claim.ClaimantFirstName = "George Anil";
            claim.ClaimantLastName  = "Washington";
            claim.Status            = StatusCode.OPEN;
            claim.LossDate          = Convert.ToDateTime("2014-07-09T17:19:13.631-07:00");
            claim.LossInfo          = new LossInfoType()
            {
                CauseOfLoss     = CauseOfLossCode.Collision,
                ReportedDate    = Convert.ToDateTime("2014-07-10T17:19:13.676-07:00"),
                LossDescription = "Crashed into an apple tree"
            };
            claim.AssignedAdjusterID = 23424;

            var result = await controller.Put(claim);

            Assert.AreEqual("Success", result);
        }