public void CanAddAnAlpacaToHerd_v0() // TODO: REF
        {
            // Arrange
            var expectedAlpaca = new
            {
                Name        = "Henry",
                Sex         = Sex.Male,
                DateOfBirth = new DateTime(2007, 7, 8),
                MarketValue = 10000
            };
            var sut = new HerdService(TestContext.DbContextFactory);

            // Act
            // -------------------------------------------------------------------
            Guid alpacaId = sut.AddAlpaca(expectedAlpaca.Name, expectedAlpaca.Sex,
                                          expectedAlpaca.DateOfBirth, expectedAlpaca.MarketValue);
            // -------------------------------------------------------------------

            // Assert
            Alpaca actualAlpaca;

            using (var dbContext = TestContext.DbContextFactory.CreateDbContext())
            {
                actualAlpaca = dbContext.Alpacas.Find(alpacaId);
            }
            Assert.Equal(expectedAlpaca.Name, actualAlpaca.Name);
            Assert.Equal(expectedAlpaca.Sex, actualAlpaca.Sex);
            Assert.Equal(expectedAlpaca.DateOfBirth, actualAlpaca.DateOfBirth);
            Assert.Equal(expectedAlpaca.MarketValue, actualAlpaca.MarketValue);
        }
        public void CanAddMultipleAlpacasToHerd_v2()
        {
            // Arrange
            var expectedAlpacas = new[] {
                new { Name = "Henry", Sex = Sex.Male, DateOfBirth = new DateTime(2007, 7, 8), MarketValue = 10000 }
                , new { Name = "Henrietta", Sex = Sex.Female, DateOfBirth = new DateTime(2007, 11, 13), MarketValue = 8000 }
                , new { Name = "Jo", Sex = Sex.Female, DateOfBirth = new DateTime(2008, 1, 8), MarketValue = 7000 }
            };
            var       sut = new HerdService(TestContext.DbContextFactory);
            const int expectedDbOperationCount = 3;

            // Act
            Guid[] alpacaIds = new Guid[3];
            var    log       = TestContext.Collect(() =>
            {
                // --------------------------------------------------------------------
                alpacaIds[0] = sut.AddAlpaca(expectedAlpacas[0].Name, expectedAlpacas[0].Sex,
                                             expectedAlpacas[0].DateOfBirth, expectedAlpacas[0].MarketValue);
                alpacaIds[1] = sut.AddAlpaca(expectedAlpacas[1].Name, expectedAlpacas[1].Sex,
                                             expectedAlpacas[1].DateOfBirth, expectedAlpacas[1].MarketValue);
                alpacaIds[2] = sut.AddAlpaca(expectedAlpacas[2].Name, expectedAlpacas[2].Sex,
                                             expectedAlpacas[2].DateOfBirth, expectedAlpacas[2].MarketValue);
                // --------------------------------------------------------------------

                return(LogCollectorProvider.GetCorrelationId());
            });

            TestContext.Attach(log);

            // Assert
            for (int i = 0; i < expectedAlpacas.Length; i++)
            {
                Alpaca actualAlpaca;
                using (var dbContext = TestContext.DbContextFactory.CreateDbContext())
                {
                    actualAlpaca = dbContext.Alpacas.Find(alpacaIds[i]);
                }
                Assert.Equal(expectedAlpacas[i].Name, actualAlpaca.Name);
                Assert.Equal(expectedAlpacas[i].Sex, actualAlpaca.Sex);
                Assert.Equal(expectedAlpacas[i].DateOfBirth, actualAlpaca.DateOfBirth);
                Assert.Equal(expectedAlpacas[i].MarketValue, actualAlpaca.MarketValue);
            }

            Assert.Equal(expectedDbOperationCount, GetLogEntryCount(log, LogCategories.EfDbCommand));
        }
        public void CanAddAnAlpacaToHerd_v1() // TODO: Ref
        {
            // Arrange
            var expectedAlpaca = new
            {
                Name        = "Henry",
                Sex         = Sex.Male,
                DateOfBirth = new DateTime(2007, 7, 8),
                MarketValue = 10000
            };
            var sut = new HerdService(TestContext.DbContextFactory);

            // Act
            Guid alpacaId = new Guid();
            var  log      = TestContext.Collect(() =>
            {
                // -------------------------------------------------------------------
                alpacaId = sut.AddAlpaca(expectedAlpaca.Name, expectedAlpaca.Sex,
                                         expectedAlpaca.DateOfBirth, expectedAlpaca.MarketValue);
                // -------------------------------------------------------------------

                return(LogCollectorProvider.GetCorrelationId());
            });

            TestContext.Attach(log);

            // Assert
            Alpaca actualAlpaca;

            using (var dbContext = TestContext.DbContextFactory.CreateDbContext())
            {
                actualAlpaca = dbContext.Alpacas.Find(alpacaId);
            }
            Assert.Equal(expectedAlpaca.Name, actualAlpaca.Name);
            Assert.Equal(expectedAlpaca.Sex, actualAlpaca.Sex);
            Assert.Equal(expectedAlpaca.DateOfBirth, actualAlpaca.DateOfBirth);
            Assert.Equal(expectedAlpaca.MarketValue, actualAlpaca.MarketValue);
        }