Пример #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);
        }
Пример #2
0
        public async Task AfterPasswordChange_ServerShouldReceiveServerWithNewPassword_OnGetClient()
        {
            var    sFixture = new ServerFixture().WithPassword("123");
            Server server   = sFixture;

            await provider.Register(DefaultUser, server);

            serverService.Raise(x => x.PasswordChanged += null, serverService.Object, sFixture.BasedOn(server).WithPassword("333").Build());

            IAdminPortClient client = provider.GetClient(DefaultUser, server);

            Assert.Equal("333", client.ServerInfo.Password);
            Assert.Equal(server.ServerIp, client.ServerInfo.ServerIp);
            Assert.Equal(server.ServerPort, client.ServerInfo.ServerPort);
        }