Пример #1
0
        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
        }
Пример #2
0
        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 );
        }