public async Task PutToggleAsync_WithoutToggleDto() { var toggle = ToggleFakeData.GetToggle1(); var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Toggle> >(); repositoryMock.Setup(r => r.FindIdAsync(toggle.Id)).Returns(Task.FromResult(toggle)); var repositoryFactoryMock = new Mock <IRepositoryFactory>(); repositoryFactoryMock.Setup(r => r.CreateRepository <Toggle>(unitoOfWorkMock.Object)).Returns(repositoryMock.Object); var manager = new ToggleBusinessManager(unitoOfWorkMock.Object, repositoryFactoryMock.Object); await manager.PutToggleAsync(null); }
public void DeleteToggleAsync_ToogleIdNotExists() { var toggle = ToggleFakeData.GetToggle1(); var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Toggle> >(); repositoryMock.Setup(r => r.GetById(toggle.Id)).Returns(default(Toggle)); var repositoryFactoryMock = new Mock <IRepositoryFactory>(); repositoryFactoryMock.Setup(r => r.CreateRepository <Toggle>(unitoOfWorkMock.Object)).Returns(repositoryMock.Object); var manager = new ToggleBusinessManager(unitoOfWorkMock.Object, repositoryFactoryMock.Object); manager.DeleteToggle(toggle.Id); }
public async Task GetToggleAsync_Ok() { var toggle = ToggleFakeData.GetToggle1(); var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Toggle> >(); repositoryMock.Setup(r => r.FindIdAsync(toggle.Id)).Returns(Task.FromResult(toggle)); var repositoryFactoryMock = new Mock <IRepositoryFactory>(); repositoryFactoryMock.Setup(r => r.CreateRepository <Toggle>(unitoOfWorkMock.Object)).Returns(repositoryMock.Object); var manager = new ToggleBusinessManager(unitoOfWorkMock.Object, repositoryFactoryMock.Object); var response = await manager.GetToggleAsync(toggle.Id); Assert.IsNotNull(response); Assert.IsNotNull(response.IsValid); Assert.AreEqual(response.Result.Id, toggle.Id); }