Esempio n. 1
0
        public void TestThatCreateCreatesProxy(bool handlesPayments)
        {
            IDataProviderProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            Guid            identifier = Guid.NewGuid();
            string          name       = _fixture.Create <string>();
            Guid            dataSourceStatementIdentifier = Guid.NewGuid();
            MySqlDataReader dataReader = CreateMySqlDataReader(identifier, name, handlesPayments, dataSourceStatementIdentifier);

            IFoodWasteDataProvider dataProvider = CreateFoodWasteDataProvider();

            IDataProviderProxy result = sut.Create(dataReader, dataProvider, "DataProviderIdentifier", "Name", "HandlesPayments", "DataSourceStatementIdentifier");

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Identifier, Is.Not.Null);
            Assert.That(result.Identifier, Is.EqualTo(identifier));
            Assert.That(result.Name, Is.Not.Null);
            Assert.That(result.Name, Is.Not.Empty);
            Assert.That(result.Name, Is.EqualTo(name));
            Assert.That(result.HandlesPayments, Is.EqualTo(handlesPayments));
            Assert.That(result.DataSourceStatementIdentifier, Is.Not.EqualTo(Guid.Empty));
            Assert.That(result.DataSourceStatementIdentifier, Is.EqualTo(dataSourceStatementIdentifier));

            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("DataProviderIdentifier")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("Name")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("HandlesPayments")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("DataSourceStatementIdentifier")), opt => opt.Repeat.Once());

            dataProvider.AssertWasNotCalled(m => m.Clone());
        }
Esempio n. 2
0
        public void TestThatMapRelationsDoesNotCloneDataProvider()
        {
            IStorageProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            IFoodWasteDataProvider dataProvider = CreateFoodWasteDataProvider();

            sut.MapRelations(dataProvider);

            dataProvider.AssertWasNotCalled(m => m.Clone());
        }
        public void TestThatMapDataMapsDataIntoProxy()
        {
            IForeignKeyProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            Guid            foreignKeyIdentifier    = Guid.NewGuid();
            Guid            foreignKeyForIdentifier = Guid.NewGuid();
            Type            foreignKeyForType       = typeof(DataProvider);
            string          foreignKeyValue         = _fixture.Create <string>();
            MySqlDataReader dataReader = CreateMySqlDataReader(foreignKeyIdentifier, foreignKeyForIdentifier, foreignKeyForType, foreignKeyValue);

            IDataProviderProxy     dataProviderProxy = BuildDataProviderProxy();
            IFoodWasteDataProvider dataProvider      = CreateFoodWasteDataProvider(dataProviderProxy);

            sut.MapData(dataReader, dataProvider);

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut.Identifier, Is.Not.Null);
            Assert.That(sut.Identifier, Is.EqualTo(foreignKeyIdentifier));
            Assert.That(sut.DataProvider, Is.Not.Null);
            Assert.That(sut.DataProvider, Is.EqualTo(dataProviderProxy));
            Assert.That(sut.ForeignKeyForIdentifier, Is.EqualTo(foreignKeyForIdentifier));
            Assert.That(sut.ForeignKeyForTypes, Is.Not.Null);
            Assert.That(sut.ForeignKeyForTypes, Is.Not.Empty);
            Assert.That(sut.ForeignKeyForTypes.Count(), Is.EqualTo(4));
            Assert.That(sut.ForeignKeyForTypes.Contains(typeof(IDomainObject)), Is.True);
            Assert.That(sut.ForeignKeyForTypes.Contains(typeof(IIdentifiable)), Is.True);
            Assert.That(sut.ForeignKeyForTypes.Contains(typeof(ITranslatable)), Is.True);
            Assert.That(sut.ForeignKeyForTypes.Contains(typeof(IDataProvider)), Is.True);
            Assert.That(sut.ForeignKeyValue, Is.Not.Null);
            Assert.That(sut.ForeignKeyValue, Is.Not.Empty);
            Assert.That(sut.ForeignKeyValue, Is.EqualTo(foreignKeyValue));

            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("ForeignKeyIdentifier")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("ForeignKeyForIdentifier")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("ForeignKeyForTypes")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("ForeignKeyValue")), opt => opt.Repeat.Once());

            dataProvider.AssertWasNotCalled(m => m.Clone());

            dataProvider.AssertWasCalled(m => m.Create(
                                             Arg <IDataProviderProxy> .Is.TypeOf,
                                             Arg <MySqlDataReader> .Is.Equal(dataReader),
                                             Arg <string[]> .Matches(e => e != null && e.Length == 4 &&
                                                                     e[0] == "DataProviderIdentifier" &&
                                                                     e[1] == "DataProviderName" &&
                                                                     e[2] == "HandlesPayments" &&
                                                                     e[3] == "DataSourceStatementIdentifier")),
                                         opt => opt.Repeat.Once());
        }
Esempio n. 4
0
        public void TestThatMapDataMapsDataIntoProxy(bool isPrimary)
        {
            IFoodItemGroupProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            Guid            foodItemGroupIdentifier = Guid.NewGuid();
            MySqlDataReader dataReader = CreateMySqlDataReader(foodItemGroupIdentifier, isPrimary);

            Guid                   foodItemIdentifier  = Guid.NewGuid();
            FoodItemProxy          foodItemProxy       = BuildFoodItemProxy(identifier: foodItemIdentifier);
            Guid                   foodGroupIdentifier = Guid.NewGuid();
            FoodGroupProxy         foodGroupProxy      = BuildFoodGroupProxy(identifier: foodGroupIdentifier);
            IFoodWasteDataProvider dataProvider        = CreateFoodWasteDataProvider(foodItemProxy, foodGroupProxy);

            sut.MapData(dataReader, dataProvider);

            Assert.That(sut.Identifier, Is.Not.Null);
            Assert.That(sut.Identifier, Is.EqualTo(foodItemGroupIdentifier));
            Assert.That(sut.FoodItem, Is.Not.Null);
            Assert.That(sut.FoodItem, Is.EqualTo(foodItemProxy));
            Assert.That(sut.FoodItemIdentifier, Is.Not.Null);
            Assert.That(sut.FoodItemIdentifier, Is.EqualTo(foodItemIdentifier));
            Assert.That(sut.FoodGroup, Is.Not.Null);
            Assert.That(sut.FoodGroup, Is.EqualTo(foodGroupProxy));
            Assert.That(sut.FoodGroupIdentifier, Is.Not.Null);
            Assert.That(sut.FoodGroupIdentifier, Is.EqualTo(foodGroupIdentifier));
            Assert.That(sut.IsPrimary, Is.EqualTo(isPrimary));

            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("FoodItemGroupIdentifier")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("IsPrimary")), opt => opt.Repeat.Once());

            dataProvider.AssertWasNotCalled(m => m.Clone());
            dataProvider.AssertWasCalled(m => m.Create(
                                             Arg <IFoodItemProxy> .Is.TypeOf,
                                             Arg <MySqlDataReader> .Is.Equal(dataReader),
                                             Arg <string[]> .Matches(e => e != null && e.Length == 2 &&
                                                                     e[0] == "FoodItemIdentifier" &&
                                                                     e[1] == "FoodItemIsActive")),
                                         opt => opt.Repeat.Once());
            dataProvider.AssertWasCalled(m => m.Create(
                                             Arg <IFoodGroupProxy> .Is.TypeOf,
                                             Arg <MySqlDataReader> .Is.Equal(dataReader),
                                             Arg <string[]> .Matches(e => e != null && e.Length == 3 &&
                                                                     e[0] == "FoodGroupIdentifier" &&
                                                                     e[1] == "FoodGroupParentIdentifier" &&
                                                                     e[2] == "FoodGroupIsActive")),
                                         opt => opt.Repeat.Once());
        }
        public void TestThatMapDataMapsDataIntoProxy(bool withBodyTranslation)
        {
            foreach (StaticTextType staticTextTypeToTest in Enum.GetValues(typeof(StaticTextType)).Cast <StaticTextType>())
            {
                IStaticTextProxy sut = CreateSut();
                Assert.That(sut, Is.Not.Null);

                Guid            staticTextIdentifier         = Guid.NewGuid();
                Guid            subjectTranslationIdentifier = Guid.NewGuid();
                Guid?           bodyTranslationIdentifier    = withBodyTranslation ? Guid.NewGuid() : (Guid?)null;
                MySqlDataReader dataReader = CreateMySqlDataReader(staticTextIdentifier, staticTextTypeToTest, subjectTranslationIdentifier, bodyTranslationIdentifier);

                IFoodWasteDataProvider dataProvider = CreateFoodWasteDataProvider();

                sut.MapData(dataReader, dataProvider);

                Assert.That(sut.Identifier, Is.Not.Null);
                Assert.That(sut.Identifier, Is.EqualTo(staticTextIdentifier));
                Assert.That(sut.Type, Is.EqualTo(staticTextTypeToTest));
                Assert.That(sut.SubjectTranslationIdentifier, Is.EqualTo(subjectTranslationIdentifier));
                if (withBodyTranslation)
                {
                    Assert.That(sut.BodyTranslationIdentifier, Is.Not.Null);
                    Assert.That(sut.BodyTranslationIdentifier, Is.EqualTo(bodyTranslationIdentifier));
                }
                else
                {
                    Assert.That(sut.BodyTranslationIdentifier, Is.Null);
                }

                dataReader.AssertWasCalled(m => m.GetString("StaticTextIdentifier"), opt => opt.Repeat.Once());
                dataReader.AssertWasCalled(m => m.GetInt16("StaticTextType"), opt => opt.Repeat.Once());
                dataReader.AssertWasCalled(m => m.GetString("SubjectTranslationIdentifier"), opt => opt.Repeat.Once());
                dataReader.AssertWasCalled(m => m.GetOrdinal("BodyTranslationIdentifier"), opt => opt.Repeat.Once());
                dataReader.AssertWasCalled(m => m.IsDBNull(Arg <int> .Is.Equal(3)), opt => opt.Repeat.Once());
                if (withBodyTranslation)
                {
                    dataReader.AssertWasCalled(m => m.GetString("BodyTranslationIdentifier"), opt => opt.Repeat.Once());
                }
                else
                {
                    dataReader.AssertWasNotCalled(m => m.GetString("BodyTranslationIdentifier"));
                }

                dataProvider.AssertWasNotCalled(m => m.Clone());
            }
        }
Esempio n. 6
0
        public void TestThatCreateCreatesProxy(bool creatable, bool editable, bool deletable)
        {
            IStorageTypeProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            Guid            storageTypeIdentifier = Guid.NewGuid();
            int             sortOrder             = _fixture.Create <int>();
            int             temperature           = _fixture.Create <int>();
            IRange <int>    temperatureRange      = DomainObjectMockBuilder.BuildIntRange();
            MySqlDataReader dataReader            = CreateMySqlDataReader(storageTypeIdentifier, sortOrder, temperature, temperatureRange, creatable, editable, deletable);

            IFoodWasteDataProvider dataProvider = CreateFoodWasteDataProvider();

            IStorageTypeProxy result = sut.Create(dataReader, dataProvider, "StorageTypeIdentifier", "SortOrder", "Temperature", "TemperatureRangeStartValue", "TemperatureRangeEndValue", "Creatable", "Editable", "Deletable");

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Identifier, Is.Not.Null);
            Assert.That(result.Identifier, Is.EqualTo(storageTypeIdentifier));
            Assert.That(result.SortOrder, Is.EqualTo(sortOrder));
            Assert.That(result.Temperature, Is.EqualTo(temperature));
            Assert.That(result.TemperatureRange, Is.Not.Null);
            Assert.That(result.TemperatureRange.StartValue, Is.EqualTo(temperatureRange.StartValue));
            Assert.That(result.TemperatureRange.EndValue, Is.EqualTo(temperatureRange.EndValue));
            Assert.That(result.Creatable, Is.EqualTo(creatable));
            Assert.That(result.Editable, Is.EqualTo(editable));
            Assert.That(result.Deletable, Is.EqualTo(deletable));

            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("StorageTypeIdentifier")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt16(Arg <string> .Is.Equal("SortOrder")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt16(Arg <string> .Is.Equal("Temperature")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt16(Arg <string> .Is.Equal("TemperatureRangeStartValue")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt16(Arg <string> .Is.Equal("TemperatureRangeEndValue")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("Creatable")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("Editable")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("Deletable")), opt => opt.Repeat.Once());

            dataProvider.AssertWasNotCalled(m => m.Clone());
        }
Esempio n. 7
0
        public void TestThatCreateCreatesProxy(bool hasDescription)
        {
            IStorageProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            Guid            identifier            = Guid.NewGuid();
            Guid            householdIdentifier   = Guid.NewGuid();
            int             sortOrder             = GetLegalSortOrder();
            Guid            storageTypeIdentifier = Guid.NewGuid();
            string          description           = hasDescription ? _fixture.Create <string>() : null;
            IRange <int>    temperatureRange      = DomainObjectMockBuilder.BuildIntRange();
            int             temperature           = GetLegalTemperature(temperatureRange);
            DateTime        creationTime          = DateTime.Now;
            MySqlDataReader dataReader            = CreateMySqlDataReader(identifier, householdIdentifier, sortOrder, storageTypeIdentifier, description, temperature, creationTime);

            HouseholdProxy         householdProxy   = BuildHouseholdProxy();
            StorageTypeProxy       storageTypeProxy = BuildStorageTypeProxy(temperatureRange: temperatureRange);
            IFoodWasteDataProvider dataProvider     = CreateFoodWasteDataProvider(householdProxy, storageTypeProxy);

            // ReSharper disable StringLiteralTypo
            IStorageProxy result = sut.Create(dataReader, dataProvider, "StorageIdentifier", "HouseholdIdentifier", "SortOrder", "StorageTypeIdentifier", "Descr", "Temperature", "CreationTime", "HouseholdName", "HouseholdDescr", "HouseholdCreationTime", "StorageTypeSortOrder", "StorageTypeTemperature", "StorageTypeTemperatureRangeStartValue", "StorageTypeTemperatureRangeEndValue", "StorageTypeCreatable", "StorageTypeEditable", "StorageTypeDeletable");

            // ReSharper restore StringLiteralTypo
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Identifier, Is.Not.Null);
            Assert.That(result.Identifier, Is.EqualTo(identifier));
            Assert.That(result.Household, Is.Not.Null);
            Assert.That(result.Household, Is.EqualTo(householdProxy));
            Assert.That(result.SortOrder, Is.EqualTo(sortOrder));
            Assert.That(result.StorageType, Is.Not.Null);
            Assert.That(result.StorageType, Is.EqualTo(storageTypeProxy));
            if (string.IsNullOrWhiteSpace(description) == false)
            {
                Assert.That(result.Description, Is.Not.Null);
                Assert.That(result.Description, Is.Not.Empty);
                Assert.That(result.Description, Is.EqualTo(description));
            }
            else
            {
                Assert.That(result.Description, Is.Null);
            }
            Assert.That(result.Temperature, Is.EqualTo(temperature));
            Assert.That(result.CreationTime, Is.EqualTo(creationTime).Within(1).Milliseconds);

            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("StorageIdentifier")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt16(Arg <string> .Is.Equal("SortOrder")), opt => opt.Repeat.Once());
            // ReSharper disable StringLiteralTypo
            dataReader.AssertWasCalled(m => m.GetOrdinal(Arg <string> .Is.Equal("Descr")), opt => opt.Repeat.Once());
            // ReSharper restore StringLiteralTypo
            dataReader.AssertWasCalled(m => m.IsDBNull(Arg <int> .Is.Equal(4)), opt => opt.Repeat.Once());
            if (string.IsNullOrWhiteSpace(description) == false)
            {
                dataReader.AssertWasCalled(m => m.GetString(Arg <int> .Is.Equal(4)), opt => opt.Repeat.Once());
            }
            else
            {
                dataReader.AssertWasNotCalled(m => m.GetString(Arg <int> .Is.Equal(4)));
            }
            dataReader.AssertWasCalled(m => m.GetInt16(Arg <string> .Is.Equal("Temperature")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetMySqlDateTime(Arg <string> .Is.Equal("CreationTime")), opt => opt.Repeat.Once());

            dataProvider.AssertWasNotCalled(m => m.Clone());

            dataProvider.AssertWasCalled(m => m.Create(
                                             Arg <IHouseholdProxy> .Is.TypeOf,
                                             Arg <MySqlDataReader> .Is.Equal(dataReader),
                                             Arg <string[]> .Matches(e => e != null && e.Length == 4 &&
                                                                     e[0] == "HouseholdIdentifier" &&
                                                                     e[1] == "HouseholdName" &&
                                                                     // ReSharper disable StringLiteralTypo
                                                                     e[2] == "HouseholdDescr" &&
                                                                     // ReSharper restore StringLiteralTypo
                                                                     e[3] == "HouseholdCreationTime")),
                                         opt => opt.Repeat.Once());

            dataProvider.AssertWasCalled(m => m.Create(
                                             Arg <IStorageTypeProxy> .Is.TypeOf,
                                             Arg <MySqlDataReader> .Is.Equal(dataReader),
                                             Arg <string[]> .Matches(e => e != null && e.Length == 8 &&
                                                                     e[0] == "StorageTypeIdentifier" &&
                                                                     e[1] == "StorageTypeSortOrder" &&
                                                                     e[2] == "StorageTypeTemperature" &&
                                                                     e[3] == "StorageTypeTemperatureRangeStartValue" &&
                                                                     e[4] == "StorageTypeTemperatureRangeEndValue" &&
                                                                     e[5] == "StorageTypeCreatable" &&
                                                                     e[6] == "StorageTypeEditable" &&
                                                                     e[7] == "StorageTypeDeletable")),
                                         opt => opt.Repeat.Once());
        }
Esempio n. 8
0
        public void TestThatMapDataMapsDataIntoProxy()
        {
            IMemberOfHouseholdProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            Guid            memberOfHouseholdIdentifier = Guid.NewGuid();
            Guid            householdMemberIdentifier   = Guid.NewGuid();
            Guid            householdIdentifier         = Guid.NewGuid();
            DateTime        creationTime = DateTime.Now;
            MySqlDataReader dataReader   = CreateMySqlDataReader(memberOfHouseholdIdentifier, householdMemberIdentifier, householdIdentifier, creationTime);

            HouseholdMemberProxy   householdMemberProxy = BuildHouseholdMemberProxy(identifier: householdMemberIdentifier);
            HouseholdProxy         householdProxy       = BuildHouseholdProxy(identifier: householdIdentifier);
            IFoodWasteDataProvider dataProvider         = CreateFoodWasteDataProvider(householdMemberProxy, householdProxy);

            sut.MapData(dataReader, dataProvider);

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut.Identifier, Is.Not.Null);
            Assert.That(sut.Identifier, Is.EqualTo(memberOfHouseholdIdentifier));
            Assert.That(sut.HouseholdMember, Is.Not.Null);
            Assert.That(sut.HouseholdMember, Is.EqualTo(householdMemberProxy));
            Assert.That(sut.HouseholdMemberIdentifier, Is.Not.Null);
            Assert.That(sut.HouseholdMemberIdentifier, Is.EqualTo(householdMemberIdentifier));
            Assert.That(sut.Household, Is.Not.Null);
            Assert.That(sut.Household, Is.EqualTo(householdProxy));
            Assert.That(sut.HouseholdIdentifier, Is.Not.Null);
            Assert.That(sut.HouseholdIdentifier, Is.EqualTo(householdIdentifier));
            Assert.That(sut.CreationTime, Is.EqualTo(creationTime).Within(1).Milliseconds);

            dataReader.AssertWasCalled(m => m.GetString("MemberOfHouseholdIdentifier"), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetMySqlDateTime("CreationTime"), opt => opt.Repeat.Once());

            dataProvider.AssertWasNotCalled(m => m.Clone());

            dataProvider.AssertWasCalled(m => m.Create(
                                             Arg <IHouseholdMemberProxy> .Is.TypeOf,
                                             Arg <MySqlDataReader> .Is.Equal(dataReader),
                                             Arg <string[]> .Matches(e => e != null && e.Length == 8 &&
                                                                     e[0] == "HouseholdMemberIdentifier" &&
                                                                     e[1] == "HouseholdMemberMailAddress" &&
                                                                     e[2] == "HouseholdMemberMembership" &&
                                                                     e[3] == "HouseholdMemberMembershipExpireTime" &&
                                                                     e[4] == "HouseholdMemberActivationCode" &&
                                                                     e[5] == "HouseholdMemberActivationTime" &&
                                                                     e[6] == "HouseholdMemberPrivacyPolicyAcceptedTime" &&
                                                                     e[7] == "HouseholdMemberCreationTime")),
                                         opt => opt.Repeat.Once());
            dataProvider.AssertWasCalled(m => m.Create(
                                             Arg <IHouseholdProxy> .Is.TypeOf,
                                             Arg <MySqlDataReader> .Is.Equal(dataReader),
                                             Arg <string[]> .Matches(e => e != null && e.Length == 4 &&
                                                                     e[0] == "HouseholdIdentifier" &&
                                                                     e[1] == "HouseholdName" &&
                                                                     // ReSharper disable StringLiteralTypo
                                                                     e[2] == "HouseholdDescr" &&
                                                                     // ReSharper restore StringLiteralTypo
                                                                     e[3] == "HouseholdCreationTime")),
                                         opt => opt.Repeat.Once());
        }
Esempio n. 9
0
        public void TestThatMapDataMapsDataIntoProxy(StakeholderType stakeholderType, bool hasPaymentReceipt)
        {
            IPaymentProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            Guid     paymentIdentifier      = Guid.NewGuid();
            Guid     stakeholderIdentifier  = Guid.NewGuid();
            Guid     dataProviderIdentifier = Guid.NewGuid();
            DateTime paymentTime            = DateTime.Now.AddDays(_random.Next(1, 7) * -1).AddMinutes(_random.Next(120, 240));
            string   paymentReference       = _fixture.Create <string>();

            byte[]          paymentReceipt = hasPaymentReceipt ? _fixture.CreateMany <byte>(_random.Next(1024, 4096)).ToArray() : null;
            DateTime        creationTime   = DateTime.Now;
            MySqlDataReader dataReader     = CreateMySqlDataReader(paymentIdentifier, stakeholderIdentifier, stakeholderType, dataProviderIdentifier, paymentTime, paymentReference, paymentReceipt, creationTime);

            DataProviderProxy      dataProviderProxy    = BuildDataProviderProxy();
            HouseholdMemberProxy   householdMemberProxy = BuildHouseholdMemberProxy();
            IFoodWasteDataProvider dataProvider         = CreateFoodWasteDataProvider(dataProviderProxy, householdMemberProxy);

            sut.MapData(dataReader, dataProvider);

            Assert.That(sut.Identifier, Is.Not.Null);
            Assert.That(sut.Identifier, Is.EqualTo(paymentIdentifier));
            Assert.That(sut.Stakeholder, Is.Not.Null);
            Assert.That(sut.Stakeholder, Is.EqualTo(householdMemberProxy));
            Assert.That(sut.DataProvider, Is.Not.Null);
            Assert.That(sut.DataProvider, Is.EqualTo(dataProviderProxy));
            Assert.That(sut.PaymentTime, Is.EqualTo(paymentTime).Within(1).Milliseconds);
            Assert.That(sut.PaymentReference, Is.Not.Null);
            Assert.That(sut.PaymentReference, Is.Not.Empty);
            Assert.That(sut.PaymentReference, Is.EqualTo(paymentReference));
            if (paymentReceipt != null)
            {
                Assert.That(sut.PaymentReceipt, Is.Not.Null);
                Assert.That(sut.PaymentReceipt, Is.Not.Empty);
                Assert.That(sut.PaymentReceipt, Is.EqualTo(paymentReceipt));
            }
            else
            {
                Assert.That(sut.PaymentReceipt, Is.Null);
            }
            Assert.That(sut.CreationTime, Is.EqualTo(creationTime).Within(1).Milliseconds);

            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("PaymentIdentifier")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("StakeholderType")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetMySqlDateTime(Arg <string> .Is.Equal("PaymentTime")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("PaymentReference")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.GetOrdinal(Arg <string> .Is.Equal("PaymentReceipt")), opt => opt.Repeat.Once());
            dataReader.AssertWasCalled(m => m.IsDBNull(Arg <int> .Is.Equal(6)), opt => opt.Repeat.Once());
            if (paymentReceipt != null)
            {
                dataReader.AssertWasCalled(m => m.GetTextReader(Arg <int> .Is.Equal(6)), opt => opt.Repeat.Once());
            }
            else
            {
                dataReader.AssertWasNotCalled(m => m.GetTextReader(Arg <int> .Is.Equal(6)));
            }
            dataReader.AssertWasCalled(m => m.GetMySqlDateTime(Arg <string> .Is.Equal("CreationTime")), opt => opt.Repeat.Once());

            dataProvider.AssertWasNotCalled(m => m.Clone());

            switch (stakeholderType)
            {
            case StakeholderType.HouseholdMember:
                dataProvider.AssertWasCalled(m => m.Create(
                                                 Arg <IHouseholdMemberProxy> .Is.TypeOf,
                                                 Arg <MySqlDataReader> .Is.Equal(dataReader),
                                                 Arg <string[]> .Matches(e => e != null && e.Length == 8 &&
                                                                         e[0] == "StakeholderIdentifier" &&
                                                                         e[1] == "HouseholdMemberMailAddress" &&
                                                                         e[2] == "HouseholdMemberMembership" &&
                                                                         e[3] == "HouseholdMemberMembershipExpireTime" &&
                                                                         e[4] == "HouseholdMemberActivationCode" &&
                                                                         e[5] == "HouseholdMemberActivationTime" &&
                                                                         e[6] == "HouseholdMemberPrivacyPolicyAcceptedTime" &&
                                                                         e[7] == "HouseholdMemberCreationTime")),
                                             opt => opt.Repeat.Once());
                break;

            default:
                throw new NotSupportedException($"The stakeholderType '{stakeholderType}' is not supported.");
            }

            dataProvider.AssertWasCalled(m => m.Create(
                                             Arg <IDataProviderProxy> .Is.TypeOf,
                                             Arg <MySqlDataReader> .Is.Equal(dataReader),
                                             Arg <string[]> .Matches(e => e != null && e.Length == 4 &&
                                                                     e[0] == "DataProviderIdentifier" &&
                                                                     e[1] == "DataProviderName" &&
                                                                     e[2] == "DataProviderHandlesPayments" &&
                                                                     e[3] == "DataProviderDataSourceStatementIdentifier")),
                                         opt => opt.Repeat.Once());
        }