public void TestThatDataGetFromTableThrowsArgumentNullExceptionIfTableIsNull() { var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest()); Assert.That(oldToNewDataRepository, Is.Not.Null); Assert.Throws <ArgumentNullException>(() => oldToNewDataRepository.DataGetFromTable(null)); }
public void TestThatDataGetFromTableThrowsDeliveryEngineRepositoryExceptionIfTableIsNotFound() { var fixture = new Fixture(); var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest()); Assert.That(oldToNewDataRepository, Is.Not.Null); var tabelMock = MockRepository.GenerateMock <ITable>(); tabelMock.Expect(m => m.NameSource) .Return(fixture.CreateAnonymous <string>()) .Repeat.Any(); fixture.Customize <ITable>(e => e.FromFactory(() => tabelMock)); Assert.Throws <DeliveryEngineRepositoryException>(() => oldToNewDataRepository.DataGetFromTable(fixture.CreateAnonymous <ITable>())); }
public void TestThatDataGetFromTableThrowsDeliveryEngineRepositoryExceptionWhenExceptionOccurs() { var fixture = new Fixture(); fixture.Customize <IDeliveryEngineMetadataExceptionInfo>(e => e.FromFactory(() => MockRepository.GenerateMock <IDeliveryEngineMetadataExceptionInfo>())); var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest()); Assert.That(oldToNewDataRepository, Is.Not.Null); var tabelMock = MockRepository.GenerateMock <ITable>(); tabelMock.Expect(m => m.NameSource) .Throw(fixture.CreateAnonymous <DeliveryEngineMetadataException>()); fixture.Customize <ITable>(e => e.FromFactory(() => tabelMock)); Assert.Throws <DeliveryEngineRepositoryException>(() => oldToNewDataRepository.DataGetFromTable(fixture.CreateAnonymous <ITable>())); }
public void TestThatDataGetFromTableThrowsDeliveryEngineSystemExceptionWhenDeliveryEngineSystemExceptionOccurs() { var fixture = new Fixture(); var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest()); Assert.That(oldToNewDataRepository, Is.Not.Null); // ReSharper disable ImplicitlyCapturedClosure oldToNewDataRepository.OnHandleData += (s, e) => { throw fixture.CreateAnonymous <DeliveryEngineSystemException>(); }; // ReSharper restore ImplicitlyCapturedClosure var fieldCollectionMock = new ObservableCollection <IField>(); var fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("SagsbehandlerID") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(int?)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(int?)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(4) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(false) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("Navn") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(25) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(true) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("Initialer") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(4) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(true) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("Kontor") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(int?)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(int?)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(2) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(true) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("Tlf") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(10) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(true) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("Epost") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(40) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(true) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); var tabelMock = MockRepository.GenerateMock <ITable>(); tabelMock.Expect(m => m.NameSource) .Return("SAGSBEH") .Repeat.Any(); tabelMock.Expect(m => m.Fields) .Return(new ReadOnlyObservableCollection <IField>(fieldCollectionMock)) .Repeat.Any(); fixture.Customize <ITable>(e => e.FromFactory(() => tabelMock)); Assert.Throws <DeliveryEngineSystemException>(() => oldToNewDataRepository.DataGetFromTable(fixture.CreateAnonymous <ITable>())); }
public void TestThatDataGetFromTableGetsDataFromTable() { var fixture = new Fixture(); var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest()); Assert.That(oldToNewDataRepository, Is.Not.Null); var tableData = new List <IEnumerable <IDataObjectBase> >(); oldToNewDataRepository.OnHandleData += (s, e) => { Assert.That(s, Is.Not.Null); Assert.That(e, Is.Not.Null); foreach (var tableRecord in e.Data) { Assert.That(tableRecord, Is.Not.Null); Assert.That(tableRecord.Count(), Is.EqualTo(6)); } tableData.AddRange(e.Data); }; var fieldCollectionMock = new ObservableCollection <IField>(); var fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("SagsbehandlerID") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(int?)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(int?)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(4) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(false) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("Navn") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(25) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(true) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("Initialer") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(4) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(true) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("Kontor") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(int?)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(int?)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(2) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(true) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("Tlf") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(10) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(true) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); fieldMock = MockRepository.GenerateMock <IField>(); fieldMock.Expect(m => m.NameSource) .Return("Epost") .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfSource) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.DatatypeOfTarget) .Return(typeof(string)) .Repeat.Any(); fieldMock.Expect(m => m.LengthOfSource) .Return(40) .Repeat.Any(); fieldMock.Expect(m => m.Nullable) .Return(true) .Repeat.Any(); fieldCollectionMock.Add(fieldMock); var tabelMock = MockRepository.GenerateMock <ITable>(); tabelMock.Expect(m => m.NameSource) .Return("SAGSBEH") .Repeat.Any(); tabelMock.Expect(m => m.Fields) .Return(new ReadOnlyObservableCollection <IField>(fieldCollectionMock)) .Repeat.Any(); fixture.Customize <ITable>(e => e.FromFactory(() => tabelMock)); oldToNewDataRepository.DataGetFromTable(fixture.CreateAnonymous <ITable>()); Assert.That(tableData, Is.Not.Null); Assert.That(tableData.Count, Is.EqualTo(7)); }