コード例 #1
0
        public async Task ShouldNotCreateInstituteIfNull()
        {
            // Arrange
            var       mockRepo   = new Mock <IAsyncRepository <Institute> >();
            var       controller = new InstituteController(mockRepo.Object);
            Institute institute  = null;

            // Act
            var result = await controller.Create(institute);

            // Assert
            Assert.IsType <BadRequestResult>(result);
        }
コード例 #2
0
        public async Task ShouldCreateInstituteIfNotNull()
        {
            // Arrange
            var mockRepo   = new Mock <IAsyncRepository <Institute> >();
            var controller = new InstituteController(mockRepo.Object);
            var institute  = new InstituteBuilder().Build();
            // Act
            var result = await controller.Create(institute);

            // Assert
            var createdAtRouteResult = Assert.IsType <CreatedAtRouteResult>(result);

            Assert.Equal("GetInstitute", createdAtRouteResult.RouteName);
            Assert.IsType <Institute>(createdAtRouteResult.Value);
        }