Example #1
0
        public void AddTestAccountUserTest()
        {
            _sqlStatus.AddUser("Test Account");
            var userIdChannelUser = _sqlStatus.GetChannelUserIdByUrlSafeName("testaccount", true);

            Assert.AreEqual(userIdChannelUser.Name, "Test Account");
        }
Example #2
0
        public ApiControllerTest()
        {
            var builder = new DbContextOptionsBuilder <AppDbContext>();

            builder.UseInMemoryDatabase(nameof(ApiControllerTest));
            var options = builder.Options;

            var provider = new ServiceCollection()
                           .AddMemoryCache()
                           .BuildServiceProvider();

            _memoryCache = provider.GetService <IMemoryCache>();


            var services = new ServiceCollection();

            // services.AddSingleton<IHubClients, FakeIHubClients>();
            // services.AddSingleton<IHubContext<DataHub>, FakeDataHub>();

            _context   = new AppDbContext(options);
            _sqlStatus = new SqlUpdateStatus(_context, _memoryCache);

            var serviceProvider = services.BuildServiceProvider();

            // _hubClients = serviceProvider.GetRequiredService<IHubClients>();
            // _dataHubContext = serviceProvider.GetRequiredService<IHubContext<DataHub>>();


            // Add example data
            var existAccount = _sqlStatus.GetChannelUserIdByUrlSafeName("testaccount", true);

            if (existAccount != null)
            {
                return;
            }

            _sqlStatus.AddUser("Test Account");

            var newUpdateStatus = new InputChannelEvent
            {
                Status = 1,
                Name   = "testaccount",
            };

            _sqlStatus.AddOrUpdate(newUpdateStatus);
        }