Пример #1
0
        public void DueListePossonoEssereSalvate()
        {
            var repository   = new MailingListRepository(new DbContext(connectionString));
            var mailingList1 = new MailingList("TestNome1")
            {
                Emails = new List <string>()
                {
                    "*****@*****.**",
                    "*****@*****.**",
                    "*****@*****.**"
                }
            };
            var mailingList2 = new MailingList("TestNome2")
            {
                Emails = new List <string>()
                {
                    "*****@*****.**",
                    "*****@*****.**",
                    "*****@*****.**"
                }
            };

            repository.Save(mailingList1);
            repository.Save(mailingList2);
            var mailingLists = repository.Get();

            Assert.Multiple(() =>
            {
                Assert.That(mailingLists.Count(), Is.EqualTo(2));
                CollectionAssert.AreEquivalent(new[] { "TestNome1", "TestNome2" }, mailingLists.Select(ml => ml.Nome));
            }
                            );
        }
Пример #2
0
        public void UnaListaPuoEssereCancellataPerId()
        {
            var repository   = new MailingListRepository(new DbContext(connectionString));
            var mailingList1 = new MailingList("TestNomeDelete")
            {
                Emails = new List <string>()
                {
                    "*****@*****.**",
                    "*****@*****.**",
                    "*****@*****.**"
                }
            };
            var mailingList2 = new MailingList("TestNomeDelete1")
            {
                Emails = new List <string>()
                {
                    "*****@*****.**",
                    "*****@*****.**",
                    "*****@*****.**"
                }
            };

            repository.Save(mailingList1);
            var idDaEliminare = mailingList1.Id;

            repository.Save(mailingList2);
            repository.Delete(idDaEliminare);
            var mailingLists = repository.Get();

            Assert.AreEqual(new string[] { mailingList2.Id }, mailingLists.Select(ml => ml.Id));
        }
Пример #3
0
        public void UnaListaPuoEssereAggiornata()
        {
            var repository  = new MailingListRepository(new DbContext(connectionString));
            var mailingList = new MailingList("TestNome")
            {
                Emails = new List <string>()
                {
                    "*****@*****.**",
                    "*****@*****.**",
                    "*****@*****.**"
                }
            };

            repository.Save(mailingList);
            mailingList.Nome = "NuovoTestNome";
            repository.Save(mailingList);
            var theOnlyMailingList = repository.Get().Single();

            Assert.That(theOnlyMailingList.Nome, Is.EqualTo("NuovoTestNome"));
        }
Пример #4
0
        public void UnaListaPuoEssereRecuperataPerId()
        {
            var repository  = new MailingListRepository(new DbContext(connectionString));
            var mailingList = new MailingList("TestNome")
            {
                Emails = new List <string>()
                {
                    "*****@*****.**",
                    "*****@*****.**",
                    "*****@*****.**"
                }
            };

            repository.Save(mailingList);
            var idAssegnato        = mailingList.Id;
            var theOnlyMailingList = repository.Get(idAssegnato);

            Assert.That(theOnlyMailingList.Id, Is.EqualTo(idAssegnato));
        }