public async Task GetApplicationsAsync_GetResponseWith2ApplicationDtos_Ok() { var apps = ApplicationFakeData.GetApplications(); var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Application> >(); repositoryMock.Setup(r => r.GetAsync()).Returns(Task.FromResult(apps)); var repositoryFactoryMock = new Mock <IRepositoryFactory>(); repositoryFactoryMock.Setup(r => r.CreateRepository <Application>(unitoOfWorkMock.Object)) .Returns(repositoryMock.Object); var manager = new ApplicationBusinessManager(unitoOfWorkMock.Object, repositoryFactoryMock.Object); var response = await manager.GetApplicationsAsync(); Assert.IsNotNull(response); Assert.IsNotNull(response.IsValid); foreach (var item in response.Result) { Assert.IsNotNull(item.Name); Assert.IsNotNull(item.Id); } }
public async Task GetTogglesAsync_WithConfigs_Ok() { var app = ApplicationFakeData.GetApplications().FirstOrDefault(); app.Configs = new List <ToggleConfig> { new ToggleConfig { Id = Guid.NewGuid().ToString(), Version = "v1", ApplicationId = app.Id, ToggleId = Guid.NewGuid().ToString() } }; var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Application> >(); repositoryMock.Setup(r => r.FindIdAsync(app.Id)).Returns(Task.FromResult(app)); var repositoryFactoryMock = new Mock <IRepositoryFactory>(); repositoryFactoryMock.Setup(r => r.CreateRepository <Application>(unitoOfWorkMock.Object)).Returns(repositoryMock.Object); var manager = new ApplicationBusinessManager(unitoOfWorkMock.Object, repositoryFactoryMock.Object); var response = await manager.GetTogglesAsync(app.Id); Assert.IsNotNull(response); Assert.IsNotNull(response.IsValid); Assert.IsNotNull(response.Result); }
public async Task GetApplicationsAsync_WithoutId() { var app = ApplicationFakeData.GetApplications().FirstOrDefault(); var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Application> >(); repositoryMock.Setup(r => r.FindIdAsync(app.Id)).Returns(Task.FromResult(app)); var repositoryFactoryMock = new Mock <IRepositoryFactory>(); repositoryFactoryMock.Setup(r => r.CreateRepository <Application>(unitoOfWorkMock.Object)).Returns(repositoryMock.Object); var manager = new ApplicationBusinessManager(unitoOfWorkMock.Object, repositoryFactoryMock.Object); await manager.GetApplicationAsync(string.Empty); }
public async Task GetApplicationAsync_Ok() { var app = ApplicationFakeData.GetApplications().FirstOrDefault(); var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Application> >(); repositoryMock.Setup(r => r.FindIdAsync(app.Id)).Returns(Task.FromResult(app)); var repositoryFactoryMock = new Mock <IRepositoryFactory>(); repositoryFactoryMock.Setup(r => r.CreateRepository <Application>(unitoOfWorkMock.Object)).Returns(repositoryMock.Object); var manager = new ApplicationBusinessManager(unitoOfWorkMock.Object, repositoryFactoryMock.Object); var response = await manager.GetApplicationAsync(app.Id); Assert.IsNotNull(response); Assert.IsTrue(response.IsValid); Assert.AreEqual(response.Result.Id, app.Id); }
public async Task GetToggleAsync_WithoutToggleSerivcePermission() { var app = ApplicationFakeData.GetApplications().FirstOrDefault(); app.IsToggleServiceAllowed = false; var unitoOfWorkMock = new Mock <IUnitOfWork <DbContext> >(); var repositoryMock = new Mock <IRepository <Application> >(); repositoryMock.Setup(r => r.FindIdAsync(app.Id)).Returns(Task.FromResult(app)); var repositoryFactoryMock = new Mock <IRepositoryFactory>(); repositoryFactoryMock.Setup(r => r.CreateRepository <Application>(unitoOfWorkMock.Object)).Returns(repositoryMock.Object); var manager = new ApplicationBusinessManager(unitoOfWorkMock.Object, repositoryFactoryMock.Object); var response = await manager.GetTogglesAsync(app.Id); Assert.IsNotNull(response); Assert.IsFalse(response.IsValid); Assert.IsNull(response.Result); Assert.IsNotNull(response.ErrorCode); Assert.IsNotNull(response.Message); }
public void GetApplications() { var apps = ApplicationFakeData.GetApplications(); AssertApplications(apps); }