public async Task GetTogglesAsync_GetResponseWith2ToggleDtos_Ok() { var toggles = ToggleFakeData.GetToggles(); var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Toggle> >(); repositoryMock.Setup(r => r.GetAsync()).Returns(Task.FromResult(toggles)); 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.GetTogglesAsync(); Assert.IsNotNull(response); Assert.IsNotNull(response.IsValid); Assert.AreEqual(response.Result.Count(), 2); foreach (var item in response.Result) { Assert.IsNotNull(item.Name); Assert.IsNotNull(item.Id); Assert.IsNotNull(item.Applications); } }
public async Task GetTogglesAsyncc_WithoutId() { var toogle = ToggleFakeData.GetToggles().FirstOrDefault(); var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Toggle> >(); repositoryMock.Setup(r => r.FindIdAsync(toogle.Id)).Returns(Task.FromResult(toogle)); 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.GetToggleAsync(string.Empty); }
public async Task GetTogglesAsync_Ok() { var toogle = ToggleFakeData.GetToggles().FirstOrDefault(); var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Toggle> >(); repositoryMock.Setup(r => r.FindIdAsync(toogle.Id)).Returns(Task.FromResult(toogle)); 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(toogle.Id); Assert.IsNotNull(response); Assert.IsNotNull(response.IsValid); Assert.AreEqual(response.Result.Id, toogle.Id); }
public void GetToggles() { var toggles = ToggleFakeData.GetToggles(); AssertToggles(toggles); }