コード例 #1
0
        public void Test_DeleteAgreement_ReturnsOkResult()
        {
            // Arrange
            var mockRepo = new Mock <IMongoDataRepository <Agreement> >();

            this.Mock.GenerateMockStations();
            List <Station> stations = this.Mock.GetAll().ToList();

            Agreement agreement = this.Mock.MockAgreement(stations);

            agreement.Id        = ObjectId.GenerateNewId();
            agreement.CreatedAt = agreement.UpdatedAt = DateTime.UtcNow;

            mockRepo.Setup(repo => repo.GetObjectByIdAsync(agreement.Id.ToString()))
            .Returns(Task.FromResult(agreement));

            var mockRepoStation = new Mock <IMongoDataRepository <Station> >();
            var controller      = new AgreementsController(mockRepo.Object, mockRepoStation.Object, Mapper);

            // Act
            var okResult = controller.DeleteAgreement(agreement.Id.ToString());

            // Assert
            Assert.IsType <OkObjectResult>(okResult.Result);
        }
コード例 #2
0
        public void Test_DeleteAgreement_ReturnsNotFoundResult()
        {
            // Arrange
            var mockRepo        = new Mock <IMongoDataRepository <Agreement> >();
            var mockRepoStation = new Mock <IMongoDataRepository <Station> >();
            var controller      = new AgreementsController(mockRepo.Object, mockRepoStation.Object, Mapper);

            // Act
            var notFoundResult = controller.DeleteAgreement(ObjectId.GenerateNewId().ToString());

            // Assert
            Assert.IsType <NotFoundResult>(notFoundResult.Result);
        }