Beispiel #1
0
        public void CreatePost_Should_Pass_Correct_Data_To_Service_Call()
        {
            // Arrange
            var userName          = "******";
            var controllerContext = new Mock <ControllerContext>();

            controllerContext.SetupGet(cc => cc.HttpContext.User.Identity.Name).Returns(userName);

            var service = new FakeServices.FakeLocationService();

            controller.LocationService = service;
            var model = GetAddLocatioTypeViewModel();

            controller.ControllerContext = controllerContext.Object;

            // Act
            var result = controller.Create(model) as RedirectToRouteResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(service.passedLocationType);
            Assert.AreEqual(service.passedLocationType.TypeName, model.TypeName);
            Assert.AreEqual(service.passedLocationType.TypeDescription, model.TypeDescription);
            Assert.AreEqual(service.passedLocationType.CreatedBy, 1);
        }
Beispiel #2
0
        public void CreatePost_Should_Call_LocationService_AddLocation()
        {
            // Arrange
            var service = new FakeServices.FakeLocationService();

            controller.LocationService = service;
            var model = GetAddLocatioTypeViewModel();

            // Act
            var result = controller.Create(model) as RedirectToRouteResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(service.AddLocationTypeWasCalled);
        }