Beispiel #1
0
        public void Test_SearchTruckId_Return_SearchTruckId_View_When_TruckId_Is_Null()
        {
            // Arrange
            var truckLocation           = MockTruckLocationViewModel();
            var truckLocationRepository = new Mock <ITruckLocationRepository>();

            truckLocationRepository.Setup(e => e.SearchTruckLocationByTruckId(truckLocation.TruckId)).Returns(truckLocation);
            var controller = new TruckTrackingController(truckLocationRepository.Object);

            // Act
            var result = controller.SearchTruckId("CM-0004") as ViewResult;

            Assert.AreEqual(result.ViewName, "TruckTracking");
        }
Beispiel #2
0
        //SearchTruckId-----------------------------------------------------
        [TestMethod] public void Test_SearchTruckId_Return_SearchTruckId_View_When_TruckId_Is_Exist()
        {
            // Arrange
            var truckLocation           = MockTruckLocationViewModel();
            var truckLocationRepository = new Mock <ITruckLocationRepository>();

            truckLocationRepository.Setup(e => e.SearchTruckLocationByTruckId(truckLocation.TruckId)).Returns(truckLocation);
            var controller = new TruckTrackingController(truckLocationRepository.Object);

            // Act
            var result = controller.SearchTruckId(truckLocation.TruckId) as ViewResult;
            var model  = result.Model;

            // Assert
            Assert.AreEqual(result.ViewName, "SearchTruckId");
            Assert.AreEqual(model, truckLocation);
        }
Beispiel #3
0
        public void Test_TruckTracking_Return_List_And_ViewName_Correct()
        {
            // Arrange
            var truckLocationList       = MockTruckLocationList();
            var truckLocationRepository = new Mock <ITruckLocationRepository>();

            truckLocationRepository.Setup(e => e.GetAllTruckLocations()).Returns(truckLocationList.AsQueryable());
            var controller = new TruckTrackingController(truckLocationRepository.Object);

            // Act
            var result = controller.TruckTracking() as ViewResult;
            var model  = result.Model;

            // Assert
            Assert.IsNotNull(model);
            Assert.AreEqual(result.ViewName, "TruckTracking");
        }
Beispiel #4
0
        public void Test_GetAllTruckLocations_Return_Json_Correct()
        {
            // Arrange
            var truckLocationList = MockTruckLocationList();
            var jsonMock          = new JsonResult {
                Data = truckLocationList
            };

            var truckLocationRepository = new Mock <ITruckLocationRepository>();

            truckLocationRepository.Setup(e => e.GetAllTruckLocations()).Returns(truckLocationList.AsQueryable());
            var controller = new TruckTrackingController(truckLocationRepository.Object);

            // Act
            var result = controller.GetAllTruckLocations() as JsonResult;

            var data = result.Data;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(data.ToString(), jsonMock.Data.ToString());
        }