Esempio n. 1
0
        public void serialize_userAdded()
        {
            var evnt = new UserCreated(Guid.NewGuid(), DateTime.Now, UserId.CreateNew(), new UserLoginInfo("prov", "key"), "username", "password");


            var settings = new JsonSerializerSettings 
            {
                TypeNameHandling = TypeNameHandling.None,
                DefaultValueHandling = DefaultValueHandling.Ignore,
                NullValueHandling = NullValueHandling.Ignore,
                ConstructorHandling = Newtonsoft.Json.ConstructorHandling.Default,
                //Formatting = Newtonsoft.Json.Formatting.Indented,
                ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver
                {
                    DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
                },
                //ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
            };

            var data = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(evnt, settings));

            var result = (UserCreated)JsonConvert.DeserializeObject(Encoding.UTF8.GetString(data), typeof(UserCreated));

            Assert.AreEqual(evnt.Id, result.Id);
            Assert.AreEqual(evnt.Timestamp, result.Timestamp);
            Assert.AreEqual(evnt.LoginInfo, result.LoginInfo);
            Assert.AreEqual(evnt.UserId, result.UserId);
        }
 void When(UserCreated evnt)
 {
     if (_users.ContainsKey(evnt.UserId.ToString()))
         return;
     var s = new ApplicationUser();
     s.Apply(evnt);
     _users.Add(evnt.UserId.ToString(), s);
 }
 internal void Apply(UserCreated evnt)
 {
     Id = evnt.UserId.ToString();
     UserName = evnt.UserName;
 }
Esempio n. 4
0
 public void Apply(UserCreated evnt)
 {
     Id         = evnt.UserId.ToString();
     _loginInfo = evnt.LoginInfo;
 }
Esempio n. 5
0
 public void Apply(UserCreated evnt)
 {
     Id = evnt.UserId.ToString();
     UserName = evnt.UserName;
     Created = evnt.Timestamp;
     LoginInfo = evnt.LoginInfo;
 }
Esempio n. 6
0
 void When(UserCreated evnt)
 {
     if (_userNames.ContainsKey(evnt.UserId.ToString()))
         return;
     _userNames[evnt.UserId.ToString()] = evnt.UserName;
 }
Esempio n. 7
0
 public void Apply(UserCreated evnt)
 {
     Id = evnt.UserId.ToString();
     _loginInfo = evnt.LoginInfo;
 }