コード例 #1
0
        public void AddDeliveredEmail_ShouldAddDeliveredEmailEntityToDb()
        {
            //SeedEmailAddresses();
            var repository = new EmailRepository(_context);

            var testDeliveredEmail = new DeliveredEmail()
            {
                Email = new Email()
                {
                    Subject     = "This is a test email sent from XUnit",
                    MessageText = "Hey man, reply when you have the chance.",
                    DateSent    = DateTime.Now,
                    MessageHtml = "Some HTML"
                },
                Receiver = new EmailAddress()
                {
                    Name  = "Me",
                    Email = "*****@*****.**"
                },
                Sender = new EmailAddress()
                {
                    Name  = "Michelle",
                    Email = "*****@*****.**"
                }
            };

            repository.AddDeliveredEmail(testDeliveredEmail);
            _context.SaveChanges();

            Assert.Equal(1, _context.DeliveredEmails.Count());
            Assert.Equal(2, _context.EmailAddresses.Count());
            Assert.Equal(1, _context.Emails.Count());
        }