Ejemplo 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.");
        }
Ejemplo n.º 2
0
        public void TestDeleteNotExistentClaim()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim testClaim      = TestDataGenerator.GetTestClaim(newClaimNumber);

            HttpResponseMessage response = ClaimsController.Post(testClaim);

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

            MitchellClaim retrievedClaim = ClaimsController.Get(newClaimNumber);

            Assert.AreEqual(testClaim, retrievedClaim, "The posted and retrieved claim should have the same values.");

            response = ClaimsController.Delete(newClaimNumber);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "Deleting an existing claim should succeed.");

            try
            {
                response = ClaimsController.Delete(newClaimNumber);
                Assert.Fail("An attempt to delete a claim that does not exist should result in an error.");
            }
            catch (HttpResponseException ex) when(ex.Response.StatusCode == HttpStatusCode.NotFound)
            {
                // This is the expected behavior
            }
        }
Ejemplo n.º 3
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.");
        }
Ejemplo n.º 4
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.");
        }
Ejemplo n.º 5
0
        public void TestPostClaimWithNoClaimNumber()
        {
            MitchellClaim testClaim = TestDataGenerator.GetTestClaim(null);

            HttpResponseMessage response = ClaimsController.Post(testClaim);

            Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode, "A POST of a claim that contains no claim number should fail with a specific status.");
        }
Ejemplo n.º 6
0
        public void TestPostClaimWithRequiredParametersNotSpecified()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim testClaim      = TestDataGenerator.GetTestClaim(newClaimNumber);

            testClaim.Vehicles[0].ModelYear = null;

            HttpResponseMessage response = ClaimsController.Post(testClaim);

            Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode, "A POST of a claim that has required fields that are not specified should fail with a specific status.");
        }
Ejemplo n.º 7
0
        public void TestPostClaimWithNoVehicles()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim testClaim      = TestDataGenerator.GetTestClaim(newClaimNumber);

            testClaim.Vehicles.Clear();

            HttpResponseMessage response = ClaimsController.Post(testClaim);

            Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode, "A POST of a claim that contains no vehicle information should fail with a specific status.");
        }
Ejemplo n.º 8
0
        public void TestPostDuplicateClaim()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim testClaim      = TestDataGenerator.GetTestClaim(newClaimNumber);

            HttpResponseMessage response = ClaimsController.Post(testClaim);

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

            response = ClaimsController.Post(testClaim);
            Assert.AreEqual(HttpStatusCode.Conflict, response.StatusCode, "A POST of a duplicate should fail with a specific status.");
        }
Ejemplo n.º 9
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.");
        }
Ejemplo n.º 10
0
        //[TestMethod]
        async public Task CreateClaimWithOutVehicleInfo()
        {
            var claim = new MitchellClaimType();

            claim.ClaimNumber       = "22c9c23bac142856018ce14a26b6c2991";
            claim.ClaimantFirstName = "George";
            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.Post(claim);

            BadRequestErrorMessageResult badRequestResult = result as BadRequestErrorMessageResult;

            Assert.AreEqual("Vehicle Details not availble in input request", badRequestResult.Message);
        }
Ejemplo n.º 11
0
        public void ClaimsController_Post()
        {
            Claim application = new Claim()
            {
                ClaimCode   = "CRUD_ACCOUNTS",
                Description = "Manage Accounts",
                Title       = "Manage Accounts Claim"
            };
            ClaimsController _controller = new ClaimsController(_mockService.Object, _logger.Object);
            var result = _controller.Post(application);

            Assert.IsNotNull(result);
        }
Ejemplo n.º 12
0
        public void TestPostSimple()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim testClaim      = TestDataGenerator.GetTestClaim(newClaimNumber);

            HttpResponseMessage response = ClaimsController.Post(testClaim);

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

            MitchellClaim retrievedClaim = ClaimsController.Get(newClaimNumber);

            Assert.AreEqual(testClaim, retrievedClaim, "The posted and retrieved claim should have the same values.");
        }
Ejemplo n.º 13
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.");
        }
Ejemplo n.º 14
0
        public void TestPostClaimWithDuplicateVehicles()
        {
            string        newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber();
            MitchellClaim testClaim      = TestDataGenerator.GetTestClaim(newClaimNumber);

            testClaim.Vehicles.Clear();
            VehicleDetails vehicleDetails = TestDataGenerator.GetTestVehicle("1M8GDM9AXKP000001");

            testClaim.Vehicles.Add(vehicleDetails);
            testClaim.Vehicles.Add(vehicleDetails);

            HttpResponseMessage response = ClaimsController.Post(testClaim);

            Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode, "A POST of a claim that contains duplicate vehicles should fail with a specific status.");
        }
Ejemplo n.º 15
0
        public void TestGetVehicleByClaimAndVin()
        {
            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.");

            VehicleDetails vehicleDetails0 = _vehiclesController.Get(newClaimNumber, expectedClaim.Vehicles[0].Vin);

            Assert.AreEqual(expectedClaim.Vehicles[0], vehicleDetails0, "GET of vehicle[0] of a claim should succeed.");

            VehicleDetails vehicleDetails1 = _vehiclesController.Get(newClaimNumber, expectedClaim.Vehicles[1].Vin);

            Assert.AreEqual(expectedClaim.Vehicles[1], vehicleDetails1, "GET of vehicle[1] of a claim should succeed.");
        }
Ejemplo n.º 16
0
        public async Task CreateClaim()
        {
            // Arrange
            Claim testClaim = new Claim
            {
                Description = "My test claim",
                Payout      = 999.99
            };

            // Act
            var result = await claimController.Post(testClaim);

            // Assert
            var createdAtActionResult = result as CreatedAtActionResult;
            var returnValue           = createdAtActionResult.Value as Claim;

            Assert.AreEqual(createdAtActionResult.StatusCode, 201);
            Assert.AreEqual(returnValue.Description, testClaim.Description);
            Assert.AreEqual(returnValue.Payout, testClaim.Payout);
        }