public void Should_get_dictionary_of_property_values()
		{
			var something = new {Value = 123, Another = "Test"};
			IDictionary<string, object> dictionary = something.ToDictionary();
			dictionary["Value"].ShouldEqual(123);
			dictionary["Another"].ShouldEqual("Test");
		}
예제 #2
0
 public static void Initialize()
 {
     var initialState = new[]
     {
         new Stall {Id = 1, Available = true, Location = "asynchrony"},
         new Stall {Id = 2, Available = true, Location = "asynchrony"},
         new Stall {Id = 3, Available = true, Location = "asynchrony"},
     };
     _cache = initialState.ToDictionary(s => s.Id);
 }
예제 #3
0
        public void should_read_from_cache_when_no_update_in_po_file()
        {
            var parser = new Mock<IPoFileParser>();
            var expectedI18NMessages = new[] { new I18NMessage("translation key", "translation key") };
            var localeEnUsMessagesPo = Path.Combine(TestHelper.GetRuntimePath(),"locale\\en-US\\messages.po");
            parser.Setup(p => p.Parse(localeEnUsMessagesPo)).Returns(expectedI18NMessages.ToDictionary(d=> d.MsgId));

            var i18NMessagesCache = new GenericCache<IDictionary<string, I18NMessage>>();
            var actualI18NMessages = i18NMessagesCache.Get("en-US", () => parser.Object.Parse(localeEnUsMessagesPo));

            VerifyResult(expectedI18NMessages, actualI18NMessages);
        }
예제 #4
0
        public void should_return_correct_translation_value_given_correct_key()
        {
            var parser = new Mock<IPoFileParser>();
            var expectedI18NMessages = new[] { new I18NMessage("translation key", "translation vlaue") };
            var localeEnUsMessagesPo = Path.Combine(TestHelper.GetRuntimePath(), "locale\\en-US\\messages.po");
            parser.Setup(p =>p.Parse(localeEnUsMessagesPo)).Returns(expectedI18NMessages.ToDictionary(d => d.MsgId));

            var i18NMessagesCache = new GenericCache<IDictionary<string, I18NMessage>>();
            var result = new LocalizingService(i18NMessagesCache, TestHelper.GetRuntimePath(), parser.Object)
                .GetText("translation key", new []{"en-US"});

            Assert.Equal("translation vlaue", result);
        }
예제 #5
0
        public static Dictionary<string, Creature> GetDictionary()
        {
            var entries = new[]
            {
                new Creature()
                {
                    Name ="Rat",
                    Health =10,
                    Damage =3
                },
                new Creature()
                {
                    Name = "Kobold",
                    Health = 15,
                    Damage = 5
                }
            };

            return entries.ToDictionary(item => item.Name);
        }
		public async Task<string> GenerateUsername(string givenName, string surName) //100%
		{
			var parameters =
				new[]
					{
						new { Key = "givenName", Value = givenName },
						new { Key = "surName", Value = surName }
					};

			var y = await Api("usernamegenerator/", parameters.ToDictionary(e => e.Key, e => e.Value));
			var x = JsonConvert.DeserializeAnonymousType(y, new { username = string.Empty });
			return x.username;
		}
		public async Task<Profile> Login(Device device, string username, string password) //99*%
		{
			//todo sort out returns
			var parameters = new[]
				{
					new { Key = "password", Value = password}
				};
			var y = await Api("profile/login/" + username, parameters.ToDictionary(e => e.Key, e => e.Value));
			var x = JsonConvert.DeserializeObject<LoginResponse>(y);

			return null;			//Don't know what data returns when logged is SUCCESSFULL - Would need ProfileID to get the profile.

			//EG "\n{\"authenticated\":false,\"verificationRequired\":false,\"forcePasswordReset\":false}"
		}