Exemple #1
0
 public static void AssertListContains(List<Author> actualAuthors, Author expectedAuthor)
 {
     foreach (var actualAuthor in actualAuthors)
     {
         if (actualAuthor.AuthorId == expectedAuthor.AuthorId)
         {
             expectedAuthor.AssertEquals(actualAuthor);
             return;
         }
     }
     Assert.Fail("Expected author with id: " + expectedAuthor.AuthorId + " was not found!");
 }
Exemple #2
0
        public void Fetch_UsingSelectCqlString()
        {
            Table<Author> table = new Table<Author>(_session, new MappingConfiguration());
            table.Create();

            var mapper = new Mapper(_session, new MappingConfiguration().Define(new FluentUserMapping()));
            List<string> followersForAuthor = new List<string>() { "follower1", "follower2", "" };
            Author expectedAuthor = new Author
            {
                AuthorId = Guid.NewGuid().ToString(),
                Followers = followersForAuthor,
            };

            mapper.Insert(expectedAuthor);
            List<Author> authors = mapper.Fetch<Author>("SELECT * from " + table.Name).ToList();
            Assert.AreEqual(1, authors.Count);
            expectedAuthor.AssertEquals(authors[0]);
        }
Exemple #3
0
        public void Fetch_ListUploadedAsNull()
        {
            Table<Author> table = new Table<Author>(_session, new MappingConfiguration());
            table.Create();
            var mapper = new Mapper(_session, new MappingConfiguration().Define(new FluentUserMapping()));
            Author expectedAuthor = Author.GetRandom();
            expectedAuthor.Followers = null;
            mapper.Insert(expectedAuthor);

            // Assert values from cql query
            Author expectedAuthorFromQuery = new Author
            {
                Followers = new List<string>(), // not null
                AuthorId = expectedAuthor.AuthorId,
            };

            Cql cql = new Cql("SELECT * from " + table.Name);
            List<Author> actualAuthors = mapper.Fetch<Author>(cql).ToList();
            Assert.AreEqual(1, actualAuthors.Count);
            expectedAuthorFromQuery.AssertEquals(actualAuthors[0]);
        }
Exemple #4
0
 public void AssertEquals(Author actualAuthor)
 {
     Assert.AreEqual(AuthorId, actualAuthor.AuthorId);
     Assert.AreEqual(Followers, actualAuthor.Followers);
 }
Exemple #5
0
 public void AssertEquals(Author actualAuthor)
 {
     Assert.AreEqual(AuthorId, actualAuthor.AuthorId);
     Assert.AreEqual(Followers, actualAuthor.Followers);
 }