public async Task CountEnabledConfigsAsyncTest()
        {
            fsq.Delete <Config>().Where("1=1").ExecuteAffrows();

            var id     = Guid.NewGuid().ToString();
            var source = new Config
            {
                AppId        = "001",
                Id           = id,
                Group        = "group",
                Key          = "key",
                Value        = "v",
                Description  = "d",
                CreateTime   = DateTime.Now,
                UpdateTime   = DateTime.Now,
                Status       = ConfigStatus.Enabled,
                OnlineStatus = OnlineStatus.Online
            };
            var id1     = Guid.NewGuid().ToString();
            var source1 = new Config
            {
                AppId        = "001",
                Id           = id1,
                Group        = "g",
                Key          = "k",
                Value        = "v",
                Description  = "d",
                CreateTime   = DateTime.Now,
                UpdateTime   = DateTime.Now,
                Status       = ConfigStatus.Deleted,
                OnlineStatus = OnlineStatus.Online
            };
            var id2     = Guid.NewGuid().ToString();
            var source2 = new Config
            {
                AppId        = "002",
                Id           = id2,
                Group        = "g",
                Key          = "k",
                Value        = "v",
                Description  = "d",
                CreateTime   = DateTime.Now,
                UpdateTime   = DateTime.Now,
                Status       = ConfigStatus.Deleted,
                OnlineStatus = OnlineStatus.Online
            };
            var result = await service.AddAsync(source);

            Assert.IsTrue(result);
            var result1 = await service.AddAsync(source1);

            Assert.IsTrue(result1);
            var result2 = await service.AddAsync(source2);

            Assert.IsTrue(result2);

            var count = await service.CountEnabledConfigsAsync();

            Assert.AreEqual(1, count);
        }
Example #2
0
        public async Task <IActionResult> ConfigCount()
        {
            var configCount = await _configService.CountEnabledConfigsAsync();

            return(Json(configCount));
        }