• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Services.ChatService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中JabbR.Services.ChatService的典型用法代码示例。如果您正苦于以下问题:C# ChatService类的具体用法?C# ChatService怎么用?C# ChatService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChatService类属于JabbR.Services命名空间,在下文中一共展示了ChatService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MakesUserOwner

            public void MakesUserOwner()
            {
                var repository = new InMemoryRepository();
                var user = new ChatUser
                {
                    Name = "foo"
                };
                var user2 = new ChatUser
                {
                    Name = "foo2"
                };
                repository.Add(user);
                repository.Add(user2);
                var room = new ChatRoom
                {
                    Name = "Room",
                    Creator = user
                };
                room.Owners.Add(user);
                user.OwnedRooms.Add(room);
                user.Rooms.Add(room);
                room.Users.Add(user);

                var service = new ChatService(repository);

                service.AddOwner(user, user2, room);

                Assert.True(room.Owners.Contains(user2));
                Assert.True(user2.OwnedRooms.Contains(room));
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:30,代码来源:ChatServiceFacts.cs


示例2: ThrowsIfNameIsInValid

            public void ThrowsIfNameIsInValid()
            {
                var repository = new InMemoryRepository();
                var service = new ChatService(new Mock<ICache>().Object, repository,new Mock<ICryptoService>().Object);

                Assert.Throws<InvalidOperationException>(() => service.AddUser("some in valid name", clientId: null, userAgent: null, password: null));
            }
开发者ID:dkouznet3,项目名称:JabbR,代码行数:7,代码来源:ChatServiceFacts.cs


示例3: MakesOwnerAllowedIfRoomLocked

            public void MakesOwnerAllowedIfRoomLocked()
            {
                var repository = new InMemoryRepository();
                var user = new ChatUser
                {
                    Name = "foo"
                };
                var user2 = new ChatUser
                {
                    Name = "foo2"
                };
                repository.Add(user);
                repository.Add(user2);
                var room = new ChatRoom
                {
                    Name = "Room",
                    Creator = user,
                    Private = true
                };
                room.Owners.Add(user);
                user.OwnedRooms.Add(room);
                user.Rooms.Add(room);
                room.Users.Add(user);

                var service = new ChatService(repository, new Mock<ICryptoService>().Object);

                service.AddOwner(user, user2, room);

                Assert.True(user2.AllowedRooms.Contains(room));
                Assert.True(room.AllowedUsers.Contains(user2));
                Assert.True(room.Owners.Contains(user2));
                Assert.True(user2.OwnedRooms.Contains(room));
            }
开发者ID:Polows,项目名称:JabbR,代码行数:33,代码来源:ChatServiceFacts.cs


示例4: ThrowsIfPasswordIsTooShort

            public void ThrowsIfPasswordIsTooShort()
            {
                var repository = new InMemoryRepository();
                var service = new ChatService(new Mock<ICache>().Object, repository,new Mock<ICryptoService>().Object);

                Assert.Throws<InvalidOperationException>(() => service.AddUser("SomeUser", clientId: null, userAgent: null, password: "short"));
            }
开发者ID:dkouznet3,项目名称:JabbR,代码行数:7,代码来源:ChatServiceFacts.cs


示例5: UnicodeNameIsValid

            public void UnicodeNameIsValid()
            {
                // Fix issue #370
                var repository = new InMemoryRepository();
                var service = new ChatService(new Mock<ICache>().Object, repository,new Mock<ICryptoService>().Object);
                var user = service.AddUser("ТарасБуга", clientId: null, userAgent: null, password: "password");

                Assert.Equal("ТарасБуга", user.Name);
            }
开发者ID:dkouznet3,项目名称:JabbR,代码行数:9,代码来源:ChatServiceFacts.cs


示例6: ThrowsIfNameInUse

            public void ThrowsIfNameInUse()
            {
                var repository = new InMemoryRepository();
                repository.Add(new ChatUser()
                {
                    Name = "taken"
                });
                var service = new ChatService(new Mock<ICache>().Object, repository,new Mock<ICryptoService>().Object);

                Assert.Throws<InvalidOperationException>(() => service.AddUser("taken", clientId: null, userAgent: null, password: null));
            }
开发者ID:dkouznet3,项目名称:JabbR,代码行数:11,代码来源:ChatServiceFacts.cs


示例7: AddsUserToRepository

            public void AddsUserToRepository()
            {
                var crypto = new Mock<ICryptoService>();
                crypto.Setup(c => c.CreateSalt()).Returns("salted");
                var repository = new InMemoryRepository();
                var service = new ChatService(new Mock<ICache>().Object, repository,crypto.Object);

                service.AddUser("SomeUser", clientId: null, userAgent: null, password: "password");

                var user = repository.GetUserByName("SomeUser");
                Assert.NotNull(user);
                Assert.Equal("SomeUser", user.Name);
                Assert.Equal("salted", user.Salt);
                Assert.Equal("8f5793009fe15c2227e3528d0507413a83dff10635d3a6acf1ba3229a03380d8", user.HashedPassword);
            }
开发者ID:dkouznet3,项目名称:JabbR,代码行数:15,代码来源:ChatServiceFacts.cs


示例8: ThrowsIfActingUserIsNotAdmin

            public void ThrowsIfActingUserIsNotAdmin()
            {
                var repository = new InMemoryRepository();
                var nonAdmin = new ChatUser
                {
                    Name = "foo"
                };
                var user = new ChatUser
                {
                    Name = "foo2"
                };
                repository.Add(nonAdmin);
                repository.Add(user);

                var service = new ChatService(new Mock<ICache>().Object, repository);

                Assert.Throws<HubException>(() => service.AddAdmin(nonAdmin, user));
            }
开发者ID:QuickenLoans,项目名称:JabbR,代码行数:18,代码来源:ChatServiceFacts.cs


示例9: ThrowsIfActingUserIsNotAdmin

            public void ThrowsIfActingUserIsNotAdmin()
            {
                var repository = new InMemoryRepository();
                var nonAdmin = new ChatUser
                {
                    Name = "foo"
                };
                var user = new ChatUser
                {
                    Name = "foo2"
                };
                repository.Add(nonAdmin);
                repository.Add(user);

                var service = new ChatService(repository, new Mock<ICryptoService>().Object);

                Assert.Throws<InvalidOperationException>(() => service.AddAdmin(nonAdmin, user));
            }
开发者ID:osbornm,项目名称:JabbR,代码行数:18,代码来源:ChatServiceFacts.cs


示例10: MakesUserAdmin

            public void MakesUserAdmin()
            {
                var repository = new InMemoryRepository();
                var admin = new ChatUser
                {
                    Name = "foo",
                    IsAdmin = true
                };
                var user = new ChatUser
                {
                    Name = "foo2",
                    IsAdmin = false
                };
                repository.Add(admin);
                repository.Add(user);

                var service = new ChatService(new Mock<ICache>().Object, repository);

                service.AddAdmin(admin, user);

                Assert.True(user.IsAdmin);
            }
开发者ID:QuickenLoans,项目名称:JabbR,代码行数:22,代码来源:ChatServiceFacts.cs


示例11: AddsNewMessageToRepository

            public void AddsNewMessageToRepository()
            {
                var repository = new InMemoryRepository();
                var user = new ChatUser
                {
                    Name = "foo"
                };
                repository.Add(user);
                var room = new ChatRoom
                {
                    Name = "Room"
                };
                repository.Add(room);
                room.Users.Add(user);
                user.Rooms.Add(room);

                var service = new ChatService(repository);
                ChatMessage message = service.AddMessage(user, room, "Content");

                Assert.NotNull(message);
                Assert.Same(message, room.Messages.First());
                Assert.Equal("Content", message.Content);
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:23,代码来源:ChatServiceFacts.cs


示例12: MarksUserAsOfflineIfNoMoreClients

            public void MarksUserAsOfflineIfNoMoreClients()
            {
                var repository = new InMemoryRepository();
                var user = new ChatUser
                {
                    Name = "foo",
                    Status = (int)UserStatus.Inactive
                };
                user.ConnectedClients.Add(new ChatClient
                {
                    Id = "foo",
                    User = user
                });

                repository.Add(user);
                var service = new ChatService(repository);

                service.DisconnectClient("foo");

                Assert.Equal(0, user.ConnectedClients.Count);
                Assert.Equal((int)UserStatus.Offline, user.Status);
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:22,代码来源:ChatServiceFacts.cs


示例13: UpatesUserPassword

            public void UpatesUserPassword()
            {
                var repository = new InMemoryRepository();
                var user = new ChatUser
                {
                    Name = "Test",
                    HashedPassword = "password".ToSha256()
                };
                repository.Add(user);
                var service = new ChatService(repository);

                service.ChangeUserPassword(user, "password", "password2");

                Assert.Equal("password2".ToSha256(), user.HashedPassword);
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:15,代码来源:ChatServiceFacts.cs


示例14: SetupNinject

        private static KernelBase SetupNinject(ApplicationSettings settings)
        {
            var kernel = new StandardKernel(new[] { new FactoryModule() });

            kernel.Bind<JabbrContext>()
                .To<JabbrContext>();

            kernel.Bind<IJabbrRepository>()
                .To<PersistedRepository>();

            kernel.Bind<IChatService>()
                  .To<ChatService>();

            kernel.Bind<IDataProtection>()
                  .To<JabbRDataProtection>();

            kernel.Bind<IFormsAuthenticationProvider>()
                  .To<JabbRFormsAuthenticationProvider>();

            kernel.Bind<ILogger>()
                  .To<RealtimeLogger>();

            // We're doing this manually since we want the chat repository to be shared
            // between the chat service and the chat hub itself
            kernel.Bind<Chat>()
                  .ToMethod(context =>
                  {
                      var resourceProcessor = context.Kernel.Get<ContentProviderProcessor>();
                      var repository = context.Kernel.Get<IJabbrRepository>();
                      var cache = context.Kernel.Get<ICache>();

                      var service = new ChatService(cache, repository);

                      return new Chat(resourceProcessor,
                                      service,
                                      repository,
                                      cache);
                  });

            kernel.Bind<ICryptoService>()
                .To<CryptoService>()
                .InSingletonScope();

            kernel.Bind<IResourceProcessor>()
                .To<ResourceProcessor>()
                .InSingletonScope();

            kernel.Bind<IApplicationSettings>()
                  .ToConstant(settings);

            kernel.Bind<IJavaScriptMinifier>()
                  .To<AjaxMinMinifier>()
                  .InSingletonScope();

            kernel.Bind<IMembershipService>()
                  .To<MembershipService>();

            kernel.Bind<IAuthenticationService>()
                  .ToConstant(new AuthenticationService());

            kernel.Bind<IAuthenticationCallbackProvider>()
                      .To<JabbRAuthenticationCallbackProvider>();

            kernel.Bind<ICache>()
                  .To<DefaultCache>()
                  .InSingletonScope();

            kernel.Bind<IChatNotificationService>()
                  .To<ChatNotificationService>();

            if (String.IsNullOrEmpty(settings.VerificationKey) ||
                String.IsNullOrEmpty(settings.EncryptionKey))
            {
                kernel.Bind<IKeyProvider>()
                      .ToConstant(new FileBasedKeyProvider());
            }
            else
            {
                kernel.Bind<IKeyProvider>()
                      .To<AppSettingKeyProvider>()
                      .InSingletonScope();
            }

            var serializer = new JsonNetSerializer(new JsonSerializerSettings()
            {
                DateFormatHandling = DateFormatHandling.IsoDateFormat
            });

            kernel.Bind<IJsonSerializer>()
                  .ToConstant(serializer);

            kernel.Bind<UploadCallbackHandler>()
                  .ToSelf()
                  .InSingletonScope();

            kernel.Bind<UploadProcessor>()
                  .ToSelf()
                  .InSingletonScope();

            kernel.Bind<ContentProviderProcessor>()
//.........这里部分代码省略.........
开发者ID:skinny,项目名称:JabbR,代码行数:101,代码来源:Startup.DependencyInjection.cs


示例15: ThrowsIfUserIsAlreadyAnOwner

            public void ThrowsIfUserIsAlreadyAnOwner()
            {
                var repository = new InMemoryRepository();
                var user = new ChatUser
                {
                    Name = "foo"
                };
                repository.Add(user);
                var room = new ChatRoom
                {
                    Name = "Room"
                };
                room.Users.Add(user);
                room.Owners.Add(user);
                user.OwnedRooms.Add(room);
                user.Rooms.Add(room);

                var service = new ChatService(repository);

                Assert.Throws<InvalidOperationException>(() => service.AddOwner(user, user, room));
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:21,代码来源:ChatServiceFacts.cs


示例16: AddsUserToRoom

            public void AddsUserToRoom()
            {
                var repository = new InMemoryRepository();
                var user = new ChatUser
                {
                    Name = "foo"
                };
                repository.Add(user);
                var room = new ChatRoom
                {
                    Name = "Room"
                };
                var service = new ChatService(repository);

                service.JoinRoom(user, room);

                Assert.True(user.Rooms.Contains(room));
                Assert.True(room.Users.Contains(user));
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:19,代码来源:ChatServiceFacts.cs


示例17: ThrowsIfUserPasswordDoesNotMatch

            public void ThrowsIfUserPasswordDoesNotMatch()
            {
                var repository = new InMemoryRepository();
                repository.Add(new ChatUser
                {
                    Name = "foo",
                    HashedPassword = "passwords".ToSha256()
                });
                var service = new ChatService(repository);

                Assert.Throws<InvalidOperationException>(() => service.AuthenticateUser("SomeUser", "foo"));
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:12,代码来源:ChatServiceFacts.cs


示例18: RemovesClientFromUserClientList

            public void RemovesClientFromUserClientList()
            {
                var repository = new InMemoryRepository();
                var user = new ChatUser
                {
                    Name = "foo",
                    Status = (int)UserStatus.Inactive
                };
                user.ConnectedClients.Add(new ChatClient
                {
                    Id = "foo",
                    User = user
                });

                user.ConnectedClients.Add(new ChatClient
                {
                    Id = "bar",
                    User = user
                });

                repository.Add(user);
                var service = new ChatService(repository);

                service.DisconnectClient("foo");

                Assert.Equal(1, user.ConnectedClients.Count);
                Assert.Equal("bar", user.ConnectedClients.First().Id);
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:28,代码来源:ChatServiceFacts.cs


示例19: ReturnsNullIfNoUserForClientId

            public void ReturnsNullIfNoUserForClientId()
            {
                var repository = new InMemoryRepository();
                var service = new ChatService(repository);

                ChatUser user = service.DisconnectClient("foo");

                Assert.Null(user);
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:9,代码来源:ChatServiceFacts.cs


示例20: DoesNotThrowIfCreatorKicksOwner

            public void DoesNotThrowIfCreatorKicksOwner()
            {
                var repository = new InMemoryRepository();
                var user = new ChatUser
                {
                    Name = "foo"
                };

                var user2 = new ChatUser
                {
                    Name = "foo2"
                };

                repository.Add(user);
                repository.Add(user2);
                var room = new ChatRoom
                {
                    Name = "Room",
                    Creator = user
                };
                user.OwnedRooms.Add(room);
                room.Owners.Add(user);

                user2.OwnedRooms.Add(room);
                room.Owners.Add(user2);

                user.Rooms.Add(room);
                user2.Rooms.Add(room);
                room.Users.Add(user);
                room.Users.Add(user2);

                var service = new ChatService(repository);

                service.KickUser(user, user2, room);

                Assert.False(user2.Rooms.Contains(room));
                Assert.False(room.Users.Contains(user2));
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:38,代码来源:ChatServiceFacts.cs



注:本文中的JabbR.Services.ChatService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ViewModels.RoomViewModel类代码示例发布时间:2022-05-26
下一篇:
C# Models.ChatUser类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap