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 TestAtConstructorInitiererBrugeraftaleProxy() { IBrugeraftaleProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); Assert.That(sut.System, Is.Not.Null); Assert.That(sut.System.Nummer, Is.EqualTo(0)); Assert.That(sut.Aftale, Is.Not.Null); Assert.That(sut.Aftale.Id, Is.EqualTo(0)); Assert.That(sut.Bruger, Is.Not.Null); Assert.That(sut.Bruger.Id, Is.EqualTo(0)); Assert.That(sut.Properties, Is.EqualTo(0)); }
public void TestAtUniqueIdReturnererIdentifikation() { int systemNo = _fixture.Create <int>(); int calId = _fixture.Create <int>(); int userId = _fixture.Create <int>(); IBrugeraftaleProxy sut = CreateSut(systemNo, calId, userId); Assert.That(sut, Is.Not.Null); string uniqueId = sut.UniqueId; Assert.That(uniqueId, Is.Not.Null); Assert.That(uniqueId, Is.EqualTo($"{Convert.ToString(systemNo)}-{Convert.ToString(calId)}-{Convert.ToString(userId)}")); }
public void TestAtCreateDeleteCommandReturnererSqlCommand() { int systemNo = _fixture.Create <int>(); int calId = _fixture.Create <int>(); int userId = _fixture.Create <int>(); IBrugeraftaleProxy sut = CreateSut(systemNo, calId, userId); Assert.That(sut, Is.Not.Null); new DbCommandTestBuilder("DELETE FROM Calmerge WHERE SystemNo=@systemNo AND CalId=@calId AND UserId=@userId") .AddSmallIntDataParameter("@systemNo", systemNo, 2) .AddIntDataParameter("@calId", calId, 8) .AddIntDataParameter("@userId", userId, 8) .Build() .Run(sut.CreateDeleteCommand()); }
public void TestAtCreateGetCommandReturnererSqlCommand() { int systemNo = _fixture.Create <int>(); int calId = _fixture.Create <int>(); int userId = _fixture.Create <int>(); IBrugeraftaleProxy sut = CreateSut(systemNo, calId, userId); Assert.That(sut, Is.Not.Null); new DbCommandTestBuilder("SELECT cm.SystemNo,cm.CalId,cm.UserId,cm.Properties,ca.Date,ca.FromTime,ca.ToTime,ca.Properties AS AppointmentProperties,ca.Subject,ca.Note,cu.UserName,cu.Name AS UserFullname,cu.Initials AS UserInitials,s.Title AS SystemTitle,s.Properties AS SystemProperties FROM Calmerge AS cm INNER JOIN Calapps AS ca ON ca.SystemNo=cm.SystemNo AND ca.CalId=cm.CalId INNER JOIN Calusers AS cu ON cu.SystemNo=cm.SystemNo AND cu.UserId=cm.UserId INNER JOIN Systems AS s ON s.SystemNo=cm.SystemNo WHERE cm.SystemNo=@systemNo AND cm.CalId=@calId AND cm.UserId=@userId") .AddSmallIntDataParameter("@systemNo", systemNo, 2) .AddIntDataParameter("@calId", calId, 8) .AddIntDataParameter("@userId", userId, 8) .Build() .Run(sut.CreateGetCommand()); }
public void TestAtCreateUpdateCommandReturnererSqlCommand() { int systemNo = _fixture.Create <int>(); int calId = _fixture.Create <int>(); int userId = _fixture.Create <int>(); int properties = _fixture.Create <int>(); IBrugeraftaleProxy sut = CreateSut(systemNo, calId, userId, properties); Assert.That(sut, Is.Not.Null); new DbCommandTestBuilder("UPDATE Calmerge SET Properties=@properties WHERE SystemNo=@systemNo AND CalId=@calId AND UserId=@userId") .AddSmallIntDataParameter("@systemNo", systemNo, 2) .AddIntDataParameter("@calId", calId, 8) .AddIntDataParameter("@userId", userId, 8) .AddSmallIntDataParameter("@properties", properties, 3, true) .Build() .Run(sut.CreateUpdateCommand()); }
public void TestAtCreateInsertCommandReturnererSqlCommand() { int systemNo = _fixture.Create <int>(); int calId = _fixture.Create <int>(); int userId = _fixture.Create <int>(); int properties = _fixture.Create <int>(); IBrugeraftaleProxy sut = CreateSut(systemNo, calId, userId, properties); Assert.That(sut, Is.Not.Null); new DbCommandTestBuilder("INSERT INTO Calmerge (SystemNo,CalId,UserId,Properties) VALUES(@systemNo,@calId,@userId,@properties)") .AddSmallIntDataParameter("@systemNo", systemNo, 2) .AddIntDataParameter("@calId", calId, 8) .AddIntDataParameter("@userId", userId, 8) .AddSmallIntDataParameter("@properties", properties, 3, true) .Build() .Run(sut.CreateInsertCommand()); }
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()); }