コード例 #1
0
        public async Task SomeValues()
        {
            try
            {
                // Run the test against one instance of the context
                using (var context = new BloggingContext(Setup.DbOpts))
                {
                    var repository = new DotnetPlayground.Repositories.HashesRepository(context, Setup.Conf, Setup.Cache, Setup.Logger, Setup.ServerTiming);
                    await repository.AddAsync(new ThinHashes
                    {
                        Key        = "alamakota",
                        HashMD5    = "dc246bcdd6cb3548579770a034d2e678",
                        HashSHA256 = "63b347973bb99fed9277b33cb4646b205e9a31331acfa574add3d2351f445e43"
                    });

                    await repository.SaveAsync();
                }

                using (var context = new BloggingContext(Setup.DbOpts))
                {
                    var repository = new DotnetPlayground.Repositories.HashesRepository(context, Setup.Conf, Setup.Cache, Setup.Logger, Setup.ServerTiming);
                    var found      = await repository.FindByAsync(x => x.HashSHA256 == "63b347973bb99fed9277b33cb4646b205e9a31331acfa574add3d2351f445e43");

                    Assert.NotNull(found);
                    Assert.NotEmpty(found);
                    Assert.Equal("alamakota", found.First().Key);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public async Task Empty_Hashes()
        {
            try
            {
                // Run the test against one instance of the context
                using (var context = new BloggingContext(Setup.DbOpts))
                {
                    var repository = new DotnetPlayground.Repositories.HashesRepository(context, Setup.Conf, Setup.Cache, Setup.Logger, Setup.ServerTiming);
                    var all        = await repository.GetAllAsync();

                    Assert.Empty(all);

                    var found = await repository.FindByAsync(x => true);

                    Assert.Empty(found);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }