public async void Update()
        {
            var mock  = new ServiceMockFacade <ITestAllFieldTypeRepository>();
            var model = new ApiTestAllFieldTypeRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <TestAllFieldType>())).Returns(Task.FromResult(new TestAllFieldType()));
            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new TestAllFieldType()));
            var service = new TestAllFieldTypeService(mock.LoggerMock.Object,
                                                      mock.RepositoryMock.Object,
                                                      mock.ModelValidatorMockFactory.TestAllFieldTypeModelValidatorMock.Object,
                                                      mock.BOLMapperMockFactory.BOLTestAllFieldTypeMapperMock,
                                                      mock.DALMapperMockFactory.DALTestAllFieldTypeMapperMock);

            UpdateResponse <ApiTestAllFieldTypeResponseModel> response = await service.Update(default(int), model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.TestAllFieldTypeModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiTestAllFieldTypeRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Update(It.IsAny <TestAllFieldType>()));
        }
Esempio n. 2
0
        public async void Update_NoErrorsOccurred_ShouldReturnResponse()
        {
            var mock  = new ServiceMockFacade <ITestAllFieldTypeService, ITestAllFieldTypeRepository>();
            var model = new ApiTestAllFieldTypeServerRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <TestAllFieldType>())).Returns(Task.FromResult(new TestAllFieldType()));
            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new TestAllFieldType()));
            var service = new TestAllFieldTypeService(mock.LoggerMock.Object,
                                                      mock.MediatorMock.Object,
                                                      mock.RepositoryMock.Object,
                                                      mock.ModelValidatorMockFactory.TestAllFieldTypeModelValidatorMock.Object,
                                                      mock.DALMapperMockFactory.DALTestAllFieldTypeMapperMock);

            UpdateResponse <ApiTestAllFieldTypeServerResponseModel> response = await service.Update(default(int), model);

            response.Should().NotBeNull();
            response.Success.Should().BeTrue();
            mock.ModelValidatorMockFactory.TestAllFieldTypeModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiTestAllFieldTypeServerRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Update(It.IsAny <TestAllFieldType>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <TestAllFieldTypeUpdatedNotification>(), It.IsAny <CancellationToken>()));
        }