protected override void OnVerify(IRepository <T> repository) { if (null == repository) { throw new ArgumentNullException("repository"); } var record = repository.Insert(Record1); record.Urn = null; RepositoryException expected = null; try { repository.Update(record); } catch (RepositoryException exception) { expected = exception; } catch (Exception exception) { throw new RepositoryTestException(Resources.Repository_UnexpectedException_ExceptionMessage, exception); } if (null == expected) { throw new RepositoryTestException(Resources.Repository_ExpectExceptionWhenRecordIncomplete_ExceptionMessage.FormatWith("Update", "URN")); } }
protected override void OnVerify(IRepository <T> repository) { if (null == repository) { throw new ArgumentNullException("repository"); } repository.Insert(Record1); RepositoryException expected = null; try { Record2.Key = AlphaDecimal.Random(); repository.Update(Record2); } catch (RepositoryException exception) { expected = exception; } catch (Exception exception) { throw new RepositoryTestException(Resources.Repository_UnexpectedException_ExceptionMessage, exception); } if (null == expected) { throw new RepositoryTestException(Resources.Repository_ExpectExceptionWhenRecordKeyNotFound_UnitTestExceptionMessage.FormatWith("Update")); } }
protected override void OnVerify(IRepository <T> repository) { if (null == repository) { throw new ArgumentNullException("repository"); } RepositoryException expected = null; try { repository.Insert(Record1); } catch (RepositoryException exception) { expected = exception; } catch (Exception exception) { throw new RepositoryTestException(Resources.Repository_UnexpectedException_ExceptionMessage, exception); } if (null == expected) { throw new RepositoryTestException(Resources.Repository_Insert_RecordKeyExists_ExceptionMessage); } }
public void ctor_SerializationInfo_StreamingContext() { var expected = new RepositoryException("test"); RepositoryException actual; using (var stream = new MemoryStream()) { var formatter = new BinaryFormatter(); formatter.Serialize(stream, new RepositoryException("test")); stream.Position = 0; actual = (RepositoryException)formatter.Deserialize(stream); } Assert.Equal(expected.Message, actual.Message); }