public void Attatch_RegistryNullValidStorage_RaiseArgumentNullException() { // arrange ISystem systemMock = this.mocks.NewMock<ISystem>(); Stub.On( systemMock ).EventAdd( "TaskStarted" ); Stub.On( systemMock ).EventAdd( "TaskEnded" ); ILogManager logManagerMock = this.mocks.NewMock<ILogManager>(); Stub.On( logManagerMock ).Method( "Trace" ).WithAnyArguments(); EntityExtension ext = new EntityExtension( "test", systemMock, logManagerMock ); IEntityExtensionPublicationStorage storageMock = this.mocks.NewMock<IEntityExtensionPublicationStorage>(); IActionRequestRegistry registry = null; IActionRequestable requestTargetMock = this.mocks.NewMock<IActionRequestable>(); IUpdateRequester updateRequesterMock = this.mocks.NewMock<IUpdateRequester>(); Stub.On( storageMock ).Method( "Publicize" ).WithAnyArguments(); Stub.On( updateRequesterMock ).EventAdd( "UpdateRequested" ); // act ext.Attatch( registry, storageMock, requestTargetMock, updateRequesterMock ); // assert }
public void EntityExtensionTest_CreateExtension_JustName_Success() { // arrange EntityExtension ext; string name = "test"; ISystem systemMock = this.mocks.NewMock<ISystem>(); Stub.On( systemMock ).EventAdd( "TaskStarted" ); Stub.On( systemMock ).EventAdd( "TaskEnded" ); ILogManager logManagerMock = this.mocks.NewMock<ILogManager>(); Stub.On( logManagerMock ).Method( "Trace" ).WithAnyArguments(); // act ext = new EntityExtension( name, systemMock, logManagerMock ); // assert Assert.IsNotNull( ext ); Assert.IsInstanceOf<EntityExtension>( ext ); Assert.IsNull( ext.PublicData ); Assert.IsFalse( ext.IsActive ); Assert.AreEqual( name, ext.Name ); }
public void Equals_IEquatable_SameNameOtherType_AreNotEqual() { // arrange ISystem systemMock = this.mocks.NewMock<ISystem>(); Stub.On( systemMock ).EventAdd( "TaskStarted" ); Stub.On( systemMock ).EventAdd( "TaskEnded" ); ILogManager logManagerMock = this.mocks.NewMock<ILogManager>(); Stub.On( logManagerMock ).Method( "Trace" ).WithAnyArguments(); EntityExtension one = new EntityExtension( "one", systemMock, logManagerMock ); EntityExtension two = new OtherExtensionTest( "one", systemMock, logManagerMock ); bool areEqual; // act areEqual = one.Equals( two as IEntityExtension ); // assert Assert.IsFalse( areEqual ); Assert.AreNotEqual( one.GetHashCode(), two.GetHashCode() ); }
public void Detatch_ValidRegistry_Success() { // arrange ISystem systemMock = this.mocks.NewMock<ISystem>(); Stub.On( systemMock ).EventAdd( "TaskStarted" ); Stub.On( systemMock ).EventAdd( "TaskEnded" ); ILogManager logManagerMock = this.mocks.NewMock<ILogManager>(); Stub.On( logManagerMock ).Method( "Trace" ).WithAnyArguments(); EntityExtension ext = new EntityExtension( "test", systemMock, logManagerMock ); IActionRequestRegistry registry = this.mocks.NewMock<IActionRequestRegistry>(); IEntityExtensionPublicationStorage storageMock = this.mocks.NewMock<IEntityExtensionPublicationStorage>(); IActionRequestable requestTargetMock = this.mocks.NewMock<IActionRequestable>(); IUpdateRequester updateRequesterMock = this.mocks.NewMock<IUpdateRequester>(); Stub.On( storageMock ).Method( "Publicize" ).WithAnyArguments(); Stub.On( updateRequesterMock ).EventAdd( "UpdateRequested" ); Stub.On( updateRequesterMock ).EventRemove( "UpdateRequested" ); ext.Attatch( registry, storageMock, requestTargetMock, updateRequesterMock ); Assert.AreEqual( storageMock, ext.PublicData ); // act ext.Detatch( registry, updateRequesterMock ); // assert Assert.IsNull( ext.PublicData ); Assert.IsFalse( ext.IsActive ); }