Example #1
0
            public void GivenNullCard_ThenThrowsArgumentNullException()
            {
                // arrange
                var repo = new JsonCardListRepository(new DirectoryInfo(@"."), new DirectoryInfo(@"."));

                // act
                repo.Save <Card>(null);

                // assert
                Assert.Fail("ArgumentNullException should have been thrown.");
            }
Example #2
0
            public void GivenValidCardToInsert_ThenSave()
            {
                // arrange
                var repo         = new JsonCardListRepository(new DirectoryInfo(@"."), new DirectoryInfo(@"."));
                var cardToInsert = new Card {
                    Name = "Test Card"
                };

                // act
                var result = repo.Save(cardToInsert);

                // assert
                Assert.AreEqual(1, repo.Data[typeof(Card)].Count);
                Assert.AreNotEqual(Guid.Empty, result);
                Assert.AreEqual(result, cardToInsert.DbId);
                Assert.AreEqual(result, repo.Data[typeof(Card)].Cast <Card>().ToList()[0].DbId);
                Assert.AreEqual(cardToInsert.Name, repo.Data[typeof(Card)].Cast <Card>().ToList()[0].Name);
            }
Example #3
0
            public void GivenValidCardToUpdate_ThenSave()
            {
                // arrange
                var id   = Guid.NewGuid();
                var repo = new JsonCardListRepository(new DirectoryInfo(@"."), new DirectoryInfo(@"."));

                repo.Data[typeof(Card)].Add(new Card {
                    DbId = id
                });
                var cardToUpdate = new Card {
                    DbId = id, Name = "Test Card"
                };

                // act
                var result = repo.Save(cardToUpdate);

                // assert
                Assert.AreEqual(1, repo.Data[typeof(Card)].Count);
                Assert.AreEqual(id, result);
                Assert.AreEqual(id, cardToUpdate.DbId);
                Assert.AreEqual(id, repo.Data[typeof(Card)].Cast <Card>().ToList()[0].DbId);
                Assert.AreEqual(cardToUpdate.Name, repo.Data[typeof(Card)].Cast <Card>().ToList()[0].Name);
            }