public void TestThatCreateCreatesCalenderUserProxy(bool hasProperties, bool hasNote) { IAftaleProxy sut = CreateSut(); Assert.That(sut, Is.Not.Null); int systemNo = _fixture.Create <int>(); int calId = _fixture.Create <int>(); DateTime fromDateTime = DateTime.Today.AddDays(_random.Next(1, 30)).AddHours(_random.Next(8, 16)).AddMinutes(_random.Next(0, 3) * 15); TimeSpan duration = new TimeSpan(0, 0, _random.Next(1, 3) * 15, 0); int? properties = hasProperties ? _fixture.Create <int>() : (int?)null; string subject = _fixture.Create <string>(); string note = hasNote ? _fixture.Create <string>() : null; MySqlDataReader dataReader = CreateMySqlDataReader(systemNo, calId, fromDateTime, duration, properties, subject, note); ISystemProxy systemProxy = MockRepository.GenerateMock <ISystemProxy>(); IMySqlDataProvider dataProvider = CreateMySqlDataProvider(systemProxy); IAftaleProxy result = sut.Create(dataReader, dataProvider, "CalId", "Date", "FromTime", "ToTime", "Properties", "Subject", "Note", "SystemNo", "SystemTitle", "SystemProperties"); Assert.That(result.System, Is.Not.Null); Assert.That(result.System, Is.EqualTo(systemProxy)); Assert.That(result.Id, Is.EqualTo(calId)); Assert.That(result.FraTidspunkt, Is.EqualTo(fromDateTime)); Assert.That(result.TilTidspunkt, Is.EqualTo(fromDateTime.Add(duration))); if (hasProperties) { Assert.That(result.Properties, Is.EqualTo(properties)); } else { Assert.That(result.Properties, Is.EqualTo(0)); } Assert.That(result.Emne, Is.Not.Null); Assert.That(result.Emne, Is.Not.Empty); Assert.That(result.Emne, Is.EqualTo(subject)); if (hasNote) { Assert.That(result.Notat, Is.Not.Null); Assert.That(result.Notat, Is.Not.Empty); Assert.That(result.Notat, Is.EqualTo(note)); } else { Assert.That(result.Notat, Is.Null); } dataReader.AssertWasCalled(m => m.GetInt32(Arg <string> .Is.Equal("CalId")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetMySqlDateTime(Arg <string> .Is.Equal("Date")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetTimeSpan(Arg <string> .Is.Equal("FromTime")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetTimeSpan(Arg <string> .Is.Equal("ToTime")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetOrdinal(Arg <string> .Is.Equal("Properties")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.IsDBNull(Arg <int> .Is.Equal(5)), 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"))); } dataReader.AssertWasCalled(m => m.GetOrdinal(Arg <string> .Is.Equal("Subject")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.IsDBNull(Arg <int> .Is.Equal(6)), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("Subject")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.GetOrdinal(Arg <string> .Is.Equal("Note")), opt => opt.Repeat.Once()); dataReader.AssertWasCalled(m => m.IsDBNull(Arg <int> .Is.Equal(7)), opt => opt.Repeat.Once()); if (hasNote) { dataReader.AssertWasCalled(m => m.GetString(Arg <string> .Is.Equal("Note")), opt => opt.Repeat.Once()); } else { dataReader.AssertWasNotCalled(m => m.GetString(Arg <string> .Is.Equal("Note"))); } 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.AssertWasNotCalled(m => m.Clone()); }