Пример #1
0
        public TestFixture()
        {
            Repository = new JsonFileRepository(JSON_FILE_NAME);

            ReviewerMostReviews = Repository.Ratings
                                  .GroupBy(r => r.Reviewer)
                                  .Select(grp => new
            {
                reviewer = grp.Key,
                reviews  = grp.Count()
            })
                                  .OrderByDescending(grp => grp.reviews)
                                  .Select(grp => grp.reviewer)
                                  .FirstOrDefault();

            MovieMostReviews = Repository.Ratings
                               .GroupBy(r => r.Movie)
                               .Select(grp => new
            {
                movie   = grp.Key,
                reviews = grp.Count()
            })
                               .OrderByDescending(grp => grp.reviews)
                               .Select(grp => grp.movie)
                               .FirstOrDefault();
        }
        public bool ConnectJsonFile()
        {
            var repo = new JsonFileRepository <Log>(Mvx.Resolve <IMvxFileStore>(), databaseName);

            Mvx.Resolve <ILogFetcher>().LoadRepo(repo);
            Mvx.Resolve <IMvxMessenger>().Publish <UpdateLogListMessage>(new UpdateLogListMessage(this, null));
            return(true);
        }
Пример #3
0
        public void TestInitialize()
        {
            var dbName = "logsDb";

            repo = new JsonFileRepository <Log>(NoSQLCoreUnitTests.testContext.DeploymentDirectory, dbName);
            repo.TruncateCollection();
            logger = new NoSqlLogger(repo);
        }
Пример #4
0
        public static void CreateScriptJson(int index = 0)
        {
            var cmdLet   = CreateCmdLet(index);
            var fileName = @"Files\Scripts.json";
            var rep      = new JsonFileRepository <CmdLet, Guid>();

            rep.Initialize(fileName);
            rep.Create(cmdLet);
        }
Пример #5
0
        public static CmdLet LoadScriptJson(string scriptName)
        {
            var fileName = @"Files\Scripts.json";
            var rep      = new JsonFileRepository <CmdLet, Guid>();

            rep.Initialize(fileName);
            var cmdLet = rep.Filter(x => x.Name == scriptName).FirstOrDefault();

            return(cmdLet);
        }
Пример #6
0
        static void Main(string[] args)
        {
            string    filepath             = "../../../../ratings.json";
            Stopwatch sw                   = Stopwatch.StartNew();
            IMovieRatingRepository repo    = new JsonFileRepository(filepath);
            MovieRatingService     service = new MovieRatingService(repo);

            sw.Stop();
            Console.WriteLine("Elapsed milliseconds: " + sw.ElapsedMilliseconds);

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(repo.Ratings[i]);
            }
        }
Пример #7
0
        public void TestInitialize()
        {
            var dbName = "NoSQLTestDb";

            // Add Sqlite plugin register. Do it only for unit tests (https://github.com/CouchBaseLite/CouchBaseLite-lite-net/wiki/Error-Dictionary#cblcs0001)
            //CouchBaseLite.Lite.Storage.SystemSQLite.Plugin.Register();

            var entityRepo           = new JsonFileRepository <TestEntity>(NoSQLCoreUnitTests.testContext.DeploymentDirectory, dbName);
            var entityRepo2          = new JsonFileRepository <TestEntity>(NoSQLCoreUnitTests.testContext.DeploymentDirectory, dbName);
            var collectionEntityRepo = new JsonFileRepository <CollectionTest>(NoSQLCoreUnitTests.testContext.DeploymentDirectory, dbName);
            var entityExtraEltRepo   = new JsonFileRepository <TestExtraEltEntity>(NoSQLCoreUnitTests.testContext.DeploymentDirectory, dbName);

            test = new NoSQLCoreUnitTests(entityRepo, entityRepo2, entityExtraEltRepo, collectionEntityRepo,
                                          NoSQLCoreUnitTests.testContext.DeploymentDirectory, dbName);
        }
Пример #8
0
 public void AddFile_AddsFile()
 {
     ILogger logger = new InMemoryLogger();
       var jsonFileRepository = new JsonFileRepository(sampleJsonFile, logger);
       jsonFileRepository.Add(new File() {
     CreatedTime = DateTime.Now.AddDays(-1),
     FolderId = 0,
     IsReadOnly = true,
     LastAccessTime = DateTime.Now,
     LastWriteTime = DateTime.Now,
     Name = "Test.txt",
     Path = System.Environment.CurrentDirectory,
     Size = 1024
       });
       File file = jsonFileRepository.GetAllFiles().Single();
       Assert.Equal("Test.txt", file.Name);
 }
Пример #9
0
 public void AddFiles_AddsFiles()
 {
     ILogger logger = new InMemoryLogger();
       var jsonFileRespository = new JsonFileRepository(sampleJsonFile, logger);
       List<File> files = new List<File>();
       for (int i = 0; i < 10; i++) {
     files.Add(new File() {
       CreatedTime = DateTime.Now.AddDays(-1),
       FolderId = 0,
       IsReadOnly = true,
       LastAccessTime = DateTime.Now,
       LastWriteTime = DateTime.Now,
       Name = "Test" + i + ".txt",
       Path = System.Environment.CurrentDirectory,
       Size = 1024
     });
       }
       jsonFileRespository.Add(files);
       Assert.Equal(files.Count, jsonFileRespository.GetAllFiles().Count());
 }
Пример #10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddAuthentication(IISDefaults.AuthenticationScheme); /*sharedOptions =>
                                                                           * {
                                                                           * // sharedOptions.DefaultScheme = IISDefaults.AuthenticationScheme;
                                                                           * sharedOptions.DefaultAuthenticateScheme = IISDefaults.AuthenticationScheme;
                                                                           * });*/

            // Add framework services.
            services.AddMvc(options => {
                options.EnableEndpointRouting = false;
            });

            // Adds a default in-memory implementation of IDistributedCache.
            services.AddDistributedMemoryCache();
            //services.AddSession(options =>
            //{
            //    options.IdleTimeout = TimeSpan.FromHours(1);
            //    options.Cookie.HttpOnly = true;
            //    options.Cookie.IsEssential = true;
            //});

            services.AddSpaStaticFiles(cfg => {
                cfg.RootPath = "wwwroot/app";
            });

            var fileSystem = new DefaultFileSystem();
            var rep        = new JsonFileRepository <Customer, string>(fileSystem);

            rep.Initialize("Data\\customers.json");
            services
            // .AddScoped<ApiExceptionFilterAttribute>()
            // .AddScoped<IConfiguration>(prov => Configuration)
            .AddScoped <IDataQuery <Customer, string> >(prov => rep)
            .AddScoped <IDataCommand <Customer, string> >(prov => rep)
            ;
        }
Пример #11
0
        public void GetAllFiles_ShouldGetAllFiles()
        {
            ILogger logger = new InMemoryLogger();
              var jsonFileRepository = new JsonFileRepository(sampleJsonFile, logger);
              int numberOfFilesToAdd = 10;

              for (int i = 0; i < numberOfFilesToAdd; i++) {
            jsonFileRepository.Add(new File() {
              CreatedTime = DateTime.Now.AddDays(-1),
              FolderId = 0,
              IsReadOnly = true,
              LastAccessTime = DateTime.Now,
              LastWriteTime = DateTime.Now,
              Name = "Test" + i + ".txt",
              Path = System.Environment.CurrentDirectory,
              Size = 1024
            });
              }

              var allFiles = jsonFileRepository.GetAllFiles();
              Assert.Equal(numberOfFilesToAdd, allFiles.Count());
        }
 public RepositoryTest()
 {
     _jsonFileName       = Path.Combine(Directory.GetCurrentDirectory(), StringExtensions.GetRandomString(10) + ".json");
     _jsonFileRepository = new JsonFileRepository <TestEntity, FilterModel>(_jsonFileName);
 }
Пример #13
0
 public void GetById_ShouldThrowException()
 {
     ILogger logger = new InMemoryLogger();
       var jsonFileRepository = new JsonFileRepository(sampleJsonFile, logger);
       Assert.Throws(typeof(NotImplementedException), () => jsonFileRepository.GetById(1));
 }