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