Beispiel #1
0
        public async Task RegisteredUsers_ShouldBeInformedAboutServerEvents_AfterServerPasswordChange()
        {
            Mock <IAdminPortClient> client = null;
            var    sFixture = new ServerFixture();
            Server server   = sFixture.WithPassword("123").Build();

            clientFactory.Setup(x => x.Create(It.IsAny <ServerInfo>())).Returns((ServerInfo si) => (client = new AdminPortClientMockFixture().WithServerInfo(si).Build()).Object);
            await provider.Register(DefaultUser, server);

            Server withPassChanged = sFixture.BasedOn(server).WithPassword("333").Build();

            serverService.Raise(x => x.PasswordChanged += null, serverService.Object, withPassChanged);

            Mock <IAdminEvent> adminEventMock = new Mock <IAdminEvent>();

            adminEventMock.SetupGet(x => x.Server).Returns(new ServerInfo(server.ServerIp, server.ServerPort, server.ServerPassword));
            client.Raise(x => x.EventReceived += null, server, adminEventMock.Object);
            defaultUserMock.Verify(x => x.ParseServerEvent(withPassChanged, adminEventMock.Object), Times.Once);
            defaultUserMock.Verify(x => x.ParseServerEvent(server, adminEventMock.Object), Times.Never);
        }
Beispiel #2
0
        public async Task AfterUnregistering_IfMoreThanOneOwnerIsStillRegistered_ThenClientShouldNOTDisconnect()
        {
            Mock <IAdminPortClient> client = null;
            Server server = new ServerFixture().WithPassword("123").Build();

            clientFactory.Setup(x => x.Create(It.IsAny <ServerInfo>())).Returns((ServerInfo si) => (client = new AdminPortClientMockFixture().WithServerInfo(si).Build()).Object);

            await provider.Register(DefaultUser, server);

            await provider.Register(Mock.Of <IAdminPortClientUser>(), server);

            await provider.Unregister(DefaultUser, server);

            client.Verify(x => x.Disconnect(), Times.Never);
        }
Beispiel #3
0
        public async Task UnregisteringThingsForUnregistered_ShouldDoNothing()
        {
            Mock <IAdminPortClient> client = null;
            Server server = new ServerFixture().WithPassword("123").Build();

            clientFactory.Setup(x => x.Create(It.IsAny <ServerInfo>())).Returns((ServerInfo si) => (client = new AdminPortClientMockFixture().WithServerInfo(si).Build()).Object);

            await provider.Register(Mock.Of <IAdminPortClientUser>(), server);

            await provider.Unregister(Mock.Of <IAdminPortClientUser>(), server);

            client.Verify(x => x.Disconnect(), Times.Never);
        }