Ejemplo n.º 1
0
        public void TestThatTranslationsMapsTranslationsIntoProxyWhenMapDataHasBeenCalledAndMapRelationsHasNotBeenCalled()
        {
            IStorageTypeProxy sut = CreateSut();

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

            Guid            storageTypeIdentifier = Guid.NewGuid();
            MySqlDataReader dataReader            = CreateMySqlDataReader(storageTypeIdentifier);

            IEnumerable <TranslationProxy> translationProxyCollection = _fixture.CreateMany <TranslationProxy>().ToList();
            IFoodWasteDataProvider         dataProvider = CreateFoodWasteDataProvider(translationProxyCollection);

            sut.MapData(dataReader, dataProvider);

            Assert.That(sut.Translation, Is.Null);
            Assert.That(sut.Translations, Is.Not.Null);
            Assert.That(sut.Translations, Is.Not.Empty);
            Assert.That(sut.Translations, Is.EqualTo(translationProxyCollection));

            dataProvider.AssertWasCalled(m => m.Clone(), opt => opt.Repeat.Once());

            IDbCommandTestExecutor commandTester = new DbCommandTestBuilder("SELECT t.TranslationIdentifier AS TranslationIdentifier,t.OfIdentifier AS OfIdentifier,ti.TranslationInfoIdentifier AS InfoIdentifier,ti.CultureName AS CultureName,t.Value AS Value FROM Translations AS t INNER JOIN TranslationInfos AS ti ON ti.TranslationInfoIdentifier=t.InfoIdentifier WHERE t.OfIdentifier=@ofIdentifier ORDER BY ti.CultureName")
                                                   .AddCharDataParameter("@ofIdentifier", storageTypeIdentifier)
                                                   .Build();

            dataProvider.AssertWasCalled(m => m.GetCollection <TranslationProxy>(Arg <MySqlCommand> .Matches(cmd => commandTester.Run(cmd))), opt => opt.Repeat.Once());
        }
Ejemplo n.º 2
0
        public void TestThatMapDataMapsDataIntoProxy(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();

            sut.MapData(dataReader, dataProvider);

            Assert.That(sut.Identifier, Is.Not.Null);
            Assert.That(sut.Identifier, Is.EqualTo(storageTypeIdentifier));
            Assert.That(sut.SortOrder, Is.EqualTo(sortOrder));
            Assert.That(sut.Temperature, Is.EqualTo(temperature));
            Assert.That(sut.TemperatureRange, Is.Not.Null);
            Assert.That(sut.TemperatureRange.StartValue, Is.EqualTo(temperatureRange.StartValue));
            Assert.That(sut.TemperatureRange.EndValue, Is.EqualTo(temperatureRange.EndValue));
            Assert.That(sut.Creatable, Is.EqualTo(creatable));
            Assert.That(sut.Editable, Is.EqualTo(editable));
            Assert.That(sut.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());
        }
Ejemplo n.º 3
0
        public void TestThatMapDataThrowsArgumentNullExceptionIfDataProviderIsNull()
        {
            IStorageTypeProxy sut = CreateSut();

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

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.MapData(CreateMySqlDataReader(), null));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "dataProvider");
        }