public void RepositoryRaSetModelAuthTest() { var modelAuth = new DataModelAuth( "111", "email", "*****@*****.**", "*****@*****.**", null, "2017-11-14T09:30:26.893Z", "https://pbs.twimg.com/profile_images/901947348699545601/hqRMHITj.jpg", null, "2017-11-17T08:43:17.669Z", "Jon", "Snow", null, "EN", false, 1510651826, 1510908197, 0, null); var authData = new UserAuthData(modelAuth); _repo = new SocialTrading.Service.Repositories.Repository(new RepositoryUserAuth(), new RepositoryUserSettings()) { ModelAuth = modelAuth }; var result = true; var fields = _repo.GetType().GetRuntimeFields(); foreach (var item in fields) { if (item.Name.Equals("_modelAuth")) { result &= Equals((item.GetValue(_repo) as Lazy <DataModelAuth>)?.Value, modelAuth); } else if (item.Name.Equals("_repositoryUserAuth")) { var repoUserAuth = item.GetValue(_repo) as RepositoryUserAuth; result &= repoUserAuth.AuthData.Equals(authData) ? true : false; } } Assert.IsTrue(result); }
public void CallConvertTimeTest() { Mock <IDateTimeConverter> dateTimeConverterMock = new Mock <IDateTimeConverter>(MockBehavior.Strict); dateTimeConverterMock.Setup(f => f.Convert("123")).Returns(It.IsAny <DateTime>()); IRepositoryPost repositoryPost = new SocialTrading.Service.Repositories.Repository(new RepositoryUserAuth(), new RepositoryUserSettings()); var fields = repositoryPost.GetType().GetRuntimeFields().ToList(); foreach (var item in fields) { if (item.Name.Equals("_converter")) { item.SetValue(repositoryPost, dateTimeConverterMock.Object); break; } } var posts = new Dictionary <string, DataModelPost> { { "123", new DataModelPost("123", "123", "123", "123", "123", 123.123f, "123", "123", "123", "123", "123", "123", "123", "123", 12, 123, true) } }; repositoryPost.SetPosts(posts); repositoryPost.GetPostHeaderModelById("123"); dateTimeConverterMock.Verify(f => f.Convert("123"), Times.AtLeastOnce); }
public void UpdatePostDoesntContainsTest() { IRepositoryPost repository = new SocialTrading.Service.Repositories.Repository(new RepositoryUserAuth(), new RepositoryUserSettings()); var posts = new Dictionary <string, DataModelPost> { { "123", new DataModelPost("123", "123", "123", "123", "123", 123.123f, "123", "123", "123", "123", "123", "123", "123", "123", 12, 123, true) } }; repository.SetPosts(posts); repository.UpdatePost(new DataModelPost("00000", "123", "123", "123", "123", 123.123f, "123", "123", "123", "123", "123", "123", "123", "123", 12, 123, true)); CollectionAssert.AreEqual((Dictionary <string, DataModelPost>)repository.GetType().GetRuntimeFields().First(f => f.Name.Equals("_posts")).GetValue(repository), posts); }