Пример #1
0
        public async Task CountEnabledAppsAsyncTest()
        {
            fsq.Delete <App>().Where("1=1").ExecuteAffrows();
            var id     = Guid.NewGuid().ToString();
            var source = new Data.Entity.App
            {
                Id         = id,
                Name       = "xx",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = true
            };
            var result = await service.AddAsync(source);

            Assert.IsTrue(result);
            var id1     = Guid.NewGuid().ToString();
            var source1 = new Data.Entity.App
            {
                Id         = id1,
                Name       = "xx",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = false
            };
            var result1 = await service.AddAsync(source1);

            Assert.IsTrue(result1);

            var count = await service.CountEnabledAppsAsync();

            Assert.AreEqual(1, count);
        }
Пример #2
0
        public async Task GetAsyncTest()
        {
            var id     = Guid.NewGuid().ToString();
            var source = new Data.Entity.App
            {
                Id         = id,
                Name       = "xx",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = true
            };
            var result = await service.AddAsync(source);

            Assert.IsTrue(result);

            var app = await service.GetAsync(id);

            Assert.IsNotNull(app);

            Assert.AreEqual(source.Id, app.Id);
            Assert.AreEqual(source.Name, app.Name);
            Assert.AreEqual(source.Secret, app.Secret);
            // Assert.AreEqual(source.CreateTime, app.CreateTime);
            // Assert.AreEqual(source.UpdateTime, app.UpdateTime);
            Assert.AreEqual(source.Enabled, app.Enabled);
        }
Пример #3
0
        public async Task DeleteAsyncTest1()
        {
            var id     = Guid.NewGuid().ToString();
            var source = new Data.Entity.App
            {
                Id         = id,
                Name       = "xx",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = true
            };
            var result = await service.AddAsync(source);

            Assert.IsTrue(result);

            var delResult = await service.DeleteAsync(id);

            Assert.IsTrue(delResult);

            var app = fsq.Select <App>(new
            {
                Id = id
            }).ToOne();

            Assert.IsNull(app);
        }
Пример #4
0
        public async Task GetAllInheritancedAppsAsyncTest()
        {
            fsq.Delete <App>().Where("1=1").ExecuteAffrows();
            var id     = Guid.NewGuid().ToString();
            var source = new Data.Entity.App
            {
                Id         = id,
                Name       = "xx",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = true,
                Type       = AppType.PRIVATE
            };
            var source1 = new Data.Entity.App
            {
                Id         = Guid.NewGuid().ToString(),
                Name       = "xxx",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = true,
                Type       = AppType.PRIVATE
            };
            var source2 = new Data.Entity.App
            {
                Id         = Guid.NewGuid().ToString(),
                Name       = "xxxx",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = true,
                Type       = AppType.Inheritance
            };
            var source3 = new Data.Entity.App
            {
                Id         = Guid.NewGuid().ToString(),
                Name       = "xxxx",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = false,
                Type       = AppType.Inheritance
            };
            var result = await service.AddAsync(source);

            await service.AddAsync(source1);

            await service.AddAsync(source2);

            await service.AddAsync(source3);

            Assert.IsTrue(result);

            var apps = await service.GetAllInheritancedAppsAsync();

            Assert.AreEqual(2, apps.Count);
        }
Пример #5
0
        public async Task UpdateAsyncTest()
        {
            var id     = Guid.NewGuid().ToString();
            var source = new Data.Entity.App
            {
                Id         = id,
                Name       = "xx",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = true
            };
            var result = await service.AddAsync(source);

            Assert.IsTrue(result);

            source.Name       = "new name";
            source.Secret     = "new sec";
            source.CreateTime = DateTime.Now.AddDays(1);
            source.UpdateTime = DateTime.Now.AddDays(1);
            source.Enabled    = false;

            var result1 = await service.UpdateAsync(source);

            Assert.IsTrue(result1);

            var app = fsq.Select <App>(new
            {
                Id = id
            }).ToOne();

            Assert.AreEqual(source.Id, app.Id);
            Assert.AreEqual(source.Name, app.Name);
            Assert.AreEqual(source.Secret, app.Secret);
            //  Assert.AreEqual(source.CreateTime, app.CreateTime);
            //  Assert.AreEqual(source.UpdateTime, app.UpdateTime);
            Assert.AreEqual(source.Enabled, app.Enabled);
        }
Пример #6
0
        public async Task GetInheritancedAppsAsyncTest()
        {
            fsq.Delete <App>().Where("1=1").ExecuteAffrows();
            fsq.Delete <AppInheritanced>().Where("1=1").ExecuteAffrows();

            var id     = Guid.NewGuid().ToString();
            var source = new Data.Entity.App
            {
                Id         = id,
                Name       = "xx",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = true,
                Type       = AppType.PRIVATE
            };
            var source1 = new Data.Entity.App
            {
                Id         = Guid.NewGuid().ToString(),
                Name       = "xx1",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = true,
                Type       = AppType.Inheritance
            };
            var source2 = new Data.Entity.App
            {
                Id         = Guid.NewGuid().ToString(),
                Name       = "xx2",
                Secret     = "sec",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                Enabled    = true,
                Type       = AppType.Inheritance
            };
            //
            var appInher = new AppInheritanced();

            appInher.Id                = Guid.NewGuid().ToString();
            appInher.AppId             = source.Id;
            appInher.InheritancedAppId = source1.Id;
            appInher.Sort              = 1;
            var appInher1 = new AppInheritanced();

            appInher1.Id                = Guid.NewGuid().ToString();
            appInher1.AppId             = source.Id;
            appInher1.InheritancedAppId = source2.Id;
            appInher1.Sort              = 2;

            var result = await service.AddAsync(source);

            await service.AddAsync(source1);

            await service.AddAsync(source2);

            fsq.Insert <AppInheritanced>(appInher).ExecuteAffrows();
            fsq.Insert <AppInheritanced>(appInher1).ExecuteAffrows();

            Assert.IsTrue(result);

            var apps = await service.GetInheritancedAppsAsync(source.Id);

            Assert.AreEqual(2, apps.Count);
        }