Example #1
0
        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);
        }
Example #2
0
        public async Task GetTogglesAsync_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.GetTogglesAsync(string.Empty);
        }
Example #3
0
        public async Task GetToggleAsync_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.GetTogglesAsync(app.Id);

            Assert.IsNotNull(response);
            Assert.IsTrue(response.IsValid);
            Assert.IsNotNull(response.Result);
        }
Example #4
0
        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);
        }