public void TestPostDelete()
        {
            // Arrange
            var controller = new StationsController(new StationLogic(new StationRepositoryStub()));

            // ACt
            var result = (ViewResult)controller.Delete(1);

            // Assert
            Assert.AreEqual("", result.ViewName);
        }
        public void TestPostDeleteStationNotExsist()
        {
            // Arrange
            var controller = new StationsController(new StationLogic(new StationRepositoryStub()));

            // ACt
            var result = controller.Delete(100) as HttpNotFoundResult;

            // Assert
            Assert.AreEqual(404, result.StatusCode);
        }
        public async Task Stations_Delete()
        {
            // Arrange
            var service    = new StationService();
            var controller = new StationsController(service);

            // Act
            var result = await controller.Delete(20);

            // Assert
            var okResult = result.Should().BeOfType <NoContentResult>().Subject;

            // should throw an eception,
            // because the station with id==20 doesn't exist enymore
            AssertionExtensions.ShouldThrow <InvalidOperationException>(
                () => service.Get(20));
        }
示例#4
0
        public void Delete()
        {
            var controller  = new StationsController(new StationBLL(new StationRepositoryStab()));
            var sessionMock = new TestControllerBuilder();

            sessionMock.InitializeController(controller);
            controller.Session["AuthenticatedUser"] = new DbUser
            {
                Username = "******",
                Password = null,
                Salt     = null
            };
            var actionResult = (RedirectToRouteResult)controller.Delete(3);

            Assert.IsNotNull(actionResult, "Not a redirect result");
            Assert.IsFalse(actionResult.Permanent);
            Assert.AreEqual("Index", actionResult.RouteValues["Action"]);
        }