Exemplo n.º 1
0
        public void ReturnAnInstanceOfDivisionTypeService_WhenDbContextIsPassed()
        {
            //Arrange
            var divisionTypeServiceMock = new Mock <IDivisionTypeService>();

            //Act
            var controller = new DivisionTypeController(divisionTypeServiceMock.Object);

            //Assert
            Assert.IsInstanceOfType(controller, typeof(DivisionTypeController));
        }
Exemplo n.º 2
0
        public void ReturnIndexView()
        {
            // Arrange
            var divisionTypeServiceMock = new Mock <IDivisionTypeService>();

            divisionTypeServiceMock.Setup(x => x.GetAllDivisionTypes()).Returns(new List <DivisionType>().AsEnumerable());

            var controller = new DivisionTypeController(divisionTypeServiceMock.Object);

            // Act & Arrange & Assert
            controller
            .WithCallTo(x => x.Index())
            .ShouldRenderDefaultView();
        }
Exemplo n.º 3
0
        public void CallGetAllDivisionTypes()
        {
            // Arrange
            var divisionTypeServiceMock = new Mock <IDivisionTypeService>();

            divisionTypeServiceMock.Setup(x => x.GetAllDivisionTypes()).Returns(new List <DivisionType>().AsEnumerable());

            var controller = new DivisionTypeController(divisionTypeServiceMock.Object);

            // Act
            controller.Index();

            // Assert
            divisionTypeServiceMock.Verify(x => x.GetAllDivisionTypes(), Times.Once);
        }
Exemplo n.º 4
0
        public void ReturnDetailsWithDivisionTypeDetailsViewModel()
        {
            // Arrange
            var expectedDivisionType = new DivisionType
            {
                Id          = Guid.NewGuid(),
                Name        = "Test",
                Description = "Test description"
            };

            var divisionTypeServiceMock = new Mock <IDivisionTypeService>();

            divisionTypeServiceMock
            .Setup(x => x.GetDivisionTypeById(expectedDivisionType.Id))
            .Returns(expectedDivisionType);

            var controller = new DivisionTypeController(divisionTypeServiceMock.Object);

            // Act & Assert
            controller
            .WithCallTo(x => x.Details(expectedDivisionType.Id))
            .ShouldRenderDefaultView()
            .WithModel <DivisionTypeDetailsViewModel>();
        }
Exemplo n.º 5
0
        public void CallGetDivisionTypeByIdOnce()
        {
            // Arrange
            var expectedDivisionType = new DivisionType
            {
                Id          = Guid.NewGuid(),
                Name        = "Test",
                Description = "Test description"
            };

            var divisionTypeServiceMock = new Mock <IDivisionTypeService>();

            divisionTypeServiceMock
            .Setup(x => x.GetDivisionTypeById(expectedDivisionType.Id))
            .Returns(expectedDivisionType);

            var controller = new DivisionTypeController(divisionTypeServiceMock.Object);

            // Act
            controller.Details(expectedDivisionType.Id);

            // Assert
            divisionTypeServiceMock.Verify(x => x.GetDivisionTypeById(expectedDivisionType.Id), Times.Once);
        }