Example #1
0
        public void TestThatTranslationsMapsTranslationsIntoProxyWhenCreateHasBeenCalledAndMapDataHasNotBeenCalled()
        {
            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);

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

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Translation, Is.Null);
            Assert.That(result.Translations, Is.Not.Null);
            Assert.That(result.Translations, Is.Not.Empty);
            Assert.That(result.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());
        }
Example #2
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());
        }
Example #3
0
        public void TestThatCreateThrowsArgumentNullExceptionIfColumnNameCollectionIsNull()
        {
            IStorageTypeProxy sut = CreateSut();

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

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

            TestHelper.AssertArgumentNullExceptionIsValid(result, "columnNameCollection");
        }
Example #4
0
        public void TestThatCreateThrowsArgumentNullExceptionIfDataProviderIsNull()
        {
            IStorageTypeProxy sut = CreateSut();

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

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Create(CreateMySqlDataReader(), null, _fixture.Create <string>(), _fixture.Create <string>(), _fixture.Create <string>()));

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