Exemple #1
0
        public void createDynamicJObjectTest1()
        {
            var factoryMock = Substitute.For <Func <string> >();
            var optionsMock = Substitute.For <IOptions <MemoryCacheOptions> >();

            optionsMock.Value.Returns(callInfo => new MemoryCacheOptions());
            var              memoryCache    = new MemoryCache(optionsMock);
            ICacheService    cacheService   = new CacheService(memoryCache);
            IConfiguration   _configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
            IFileRead        read           = new FileRead(_configuration, cacheService);
            IJsonDataService jsonService    = new JsonDataService(_configuration, cacheService, read);

            var countries = jsonService.GetCountries();

            string        codesJson  = read.ReadJsonFile("Json,codes2.json");
            List <Code>   codes      = JsonConvert.DeserializeObject <List <Code> >(codesJson);
            List <string> missingCN2 = new List <string>();
            List <string> missingCN3 = new List <string>();

            foreach (var c in codes)
            {
                var found = countries.FirstOrDefault(a => a.CountryName == c.CountryName);
                if (found == null)
                {
                    missingCN2.Add(c.CountryName);
                }
                else
                {
                    missingCN3.Add(c.CountryName);
                }
            }
            Action act = () => missingCN2.Count.Should().BeGreaterThan(0);

            act.Should().NotThrow();
        }
Exemple #2
0
        public void GetCountries_Test()
        {
            var factoryMock = Substitute.For <Func <string> >();
            var optionsMock = Substitute.For <IOptions <MemoryCacheOptions> >();

            optionsMock.Value.Returns(callInfo => new MemoryCacheOptions());
            var           memoryCache  = new MemoryCache(optionsMock);
            ICacheService cacheService = new CacheService(memoryCache);

            IConfiguration _configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
            IFileRead      read           = new FileRead(_configuration, cacheService);

            IJsonDataService jsonService = new JsonDataService(_configuration, cacheService, read);
            var    list = jsonService.GetCountries();
            Action act  = () => list.Count.Should().BeGreaterThan(0);

            act.Should().NotThrow();
        }