public void TestAtMapDataKasterArgumentNullExceptionHvisDataProviderErNull() { IBrugeraftaleProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.MapData(CreateMySqlDataReader(), null)); TestHelper.AssertArgumentNullExceptionIsValid(result, "dataProvider"); }
public void TestAtMapDataMapperBrugeraftaleProxy(bool hasProperties) { IBrugeraftaleProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); int systemNo = _fixture.Create <int>(); int calId = _fixture.Create <int>(); int userId = _fixture.Create <int>(); int? properties = hasProperties ? _fixture.Create <int>() : (int?)null; MySqlDataReader dataReader = CreateMySqlDataReader(systemNo, calId, userId, properties); ISystemProxy systemProxy = MockRepository.GenerateMock <ISystemProxy>(); IAftaleProxy appointmentProxy = MockRepository.GenerateMock <IAftaleProxy>(); IBrugerProxy calenderUserProxy = MockRepository.GenerateMock <IBrugerProxy>(); IMySqlDataProvider dataProvider = CreateMySqlDataProvider(systemProxy, appointmentProxy, calenderUserProxy); sut.MapData(dataReader, dataProvider); Assert.That(sut.System, Is.Not.Null); Assert.That(sut.System, Is.EqualTo(systemProxy)); Assert.That(sut.Aftale, Is.Not.Null); Assert.That(sut.Aftale, Is.EqualTo(appointmentProxy)); Assert.That(sut.Bruger, Is.Not.Null); Assert.That(sut.Bruger, Is.EqualTo(calenderUserProxy)); if (hasProperties) { Assert.That(sut.Properties, Is.EqualTo(properties)); } else { Assert.That(sut.Properties, Is.EqualTo(0)); } dataReader.AssertWasCalled(m => m.GetOrdinal(Arg <string> .Is.Equal("Properties")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.IsDBNull(Arg <int> .Is.Equal(3)), opt => opt.Repeat.Once()); if (hasProperties) { dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("Properties")), opt => opt.Repeat.Once()); } else { dataReader.AssertWasNotCalled(m => m.GetInt32(Arg <string> .Is.Equal("Properties"))); } dataProvider.AssertWasCalled(m => m.Create( Arg <ISystemProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Equal(dataReader), Arg <string[]> .Matches(e => e != null && e.Length == 3 && e[0] == "SystemNo" && e[1] == "SystemTitle" && e[2] == "SystemProperties")), opt => opt.Repeat.Once()); dataProvider.AssertWasCalled(m => m.Create( Arg <IAftaleProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Equal(dataReader), Arg <string[]> .Matches(e => e != null && e.Length == 10 && e[0] == "CalId" && e[1] == "Date" && e[2] == "FromTime" && e[3] == "ToTime" && e[4] == "AppointmentProperties" && e[5] == "Subject" && e[6] == "Note" && e[7] == "SystemNo" && e[8] == "SystemTitle" && e[9] == "SystemProperties")), opt => opt.Repeat.Once()); dataProvider.AssertWasCalled(m => m.Create( Arg <IBrugerProxy> .Is.TypeOf, Arg <MySqlDataReader> .Is.Equal(dataReader), Arg <string[]> .Matches(e => e != null && e.Length == 7 && e[0] == "UserId" && e[1] == "UserInitials" && e[2] == "UserFullname" && e[3] == "UserName" && e[4] == "SystemNo" && e[5] == "SystemTitle" && e[6] == "SystemProperties")), opt => opt.Repeat.Once()); }