예제 #1
0
        public void GetById_DictionaryNotNull()
        {
            AppSettingsDictionaryResolverBase configurationResolverBase = new AppSettingsDictionaryResolverBase("DictionaryConfiguration.json", "Dictionary1");
            var Dictionary = configurationResolverBase.GetById("Config1");

            Assert.NotNull(Dictionary);
        }
예제 #2
0
        public void GetById_CountShouldBe3()
        {
            AppSettingsDictionaryResolverBase configurationResolverBase = new AppSettingsDictionaryResolverBase("DictionaryConfiguration.json", "Dictionary1");
            var Dictionary = configurationResolverBase.GetById("Config2");

            Assert.AreEqual(Dictionary.Count, 3);
        }
예제 #3
0
        public void GetById_ShouldFail()
        {
            AppSettingsDictionaryResolverBase configurationResolverBase = new AppSettingsDictionaryResolverBase("DictionaryConfiguration.json", "Dictionary1");

            Assert.Throws <ArgumentException>(() =>
                                              configurationResolverBase.GetById("db99")
                                              );
        }
예제 #4
0
        public void GenerateValidToken_ShouldPass()
        {
            var Dictionary = _configurationResolverBase.GetById("db1");

            JwtService service = new JwtService(Dictionary["Key"], Dictionary["ValidIssuer"]);

            JwtPayload InitialPayload;

            InitialPayload = new JwtPayload {
                { "UserOid ", "001" },
                { JwtRegisteredClaimNames.Iat, service.DateToNumber(DateTime.Now).ToString() },
                { JwtRegisteredClaimNames.Iss, Dictionary["ValidIssuer"] },
            };

            var StringToken = service.JwtPayloadToToken(InitialPayload);

            Debug.WriteLine(string.Format("{0}:{1}", "Token", StringToken));


            Assert.True(service.VerifyToken(StringToken));
        }
예제 #5
0
        public void ConfigurationResolverBase_ResolveRuntime_ShouldPass()
        {
            AppSettingsDictionaryResolverBase configurationResolverBase = new AppSettingsDictionaryResolverBase("TestDictionaryConfiguration.json", "Dictionary1");


            //var builder = new ConfigurationBuilder()
            //               .SetBasePath(Directory.GetCurrentDirectory())
            //               .AddJsonFile("appsettings.json");
            //builder.Build();


            var NewConfig = File.ReadAllText("NewDictionaryConfiguration.json");

            File.WriteAllText("TestDictionaryConfiguration.json", NewConfig);

            var NewItem = configurationResolverBase.GetById("NewItem");

            Assert.NotNull(NewItem);
        }