public void CanAddMultipleAlpacasToHerdAsync_v1() // TODO: REF
        {
            // 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[0];
            var    log       = TestContext.Collect(() =>
            {
                // --------------------------------------------------------------------
                alpacaIds = Task.WhenAll(
                    sut.AddAlpacaAsync(expectedAlpacas[0].Name, expectedAlpacas[0].Sex,
                                       expectedAlpacas[0].DateOfBirth, expectedAlpacas[0].MarketValue),
                    sut.AddAlpacaAsync(expectedAlpacas[1].Name, expectedAlpacas[1].Sex,
                                       expectedAlpacas[1].DateOfBirth, expectedAlpacas[1].MarketValue),
                    sut.AddAlpacaAsync(expectedAlpacas[2].Name, expectedAlpacas[2].Sex,
                                       expectedAlpacas[2].DateOfBirth, expectedAlpacas[2].MarketValue)
                    ).GetAwaiter().GetResult();
                // --------------------------------------------------------------------

                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)); // Expected to fail - operations not captured properly.
        }
        public void CanAddAnAlpacaToHerdAsync_v1()
        {
            // Arrange
            var expectedAlpaca = new
            {
                Name        = "Henry",
                Sex         = Sex.Male,
                DateOfBirth = new DateTime(2007, 7, 8),
                MarketValue = 10000
            };
            var       sut = new HerdService(TestContext.DbContextFactory);
            const int expectedDbOperations = 1;

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

                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);

            Assert.Equal(expectedDbOperations, GetLogEntryCount(log, LogCategories.EfDbCommand));
        }