public void When_Creating_With_No_Extensions_Then_Add_Extensions() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); Tuple <string, string> files = _business.GetSaveFilesNames(); Assert.AreEqual(Path.GetExtension(files.Item1), ".xml"); Assert.AreEqual(Path.GetExtension(files.Item2), ".xml"); }
public static void Main() { ServerBusiness servBus = new ServerBusiness(); var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(queue: "rpc_queue", durable: false, exclusive: false, autoDelete: false, arguments: null); channel.BasicQos(0, 1, false); var consumer = new EventingBasicConsumer(channel); channel.BasicConsume(queue: "rpc_queue", autoAck: false, consumer: consumer); Console.WriteLine("Server Awaiting RPC requests"); consumer.Received += (model, ea) => { string response = null; var body = ea.Body; var props = ea.BasicProperties; var replyProps = channel.CreateBasicProperties(); replyProps.CorrelationId = props.CorrelationId; try { var message = Encoding.UTF8.GetString(body); Console.WriteLine("Client Recieves {0}", message); if (message == "SendCurveNames") { string ExtractedColumns = servBus.ReadCurveNames(message); response = ExtractedColumns; Console.WriteLine("Client Returns {0}", response); } else { string Extractedcurves = servBus.ReadCSV(message); response = Extractedcurves; Console.WriteLine("Client Returns {0}", response); } } catch (Exception e) { Console.WriteLine(" [.] " + e.Message); response = ""; } finally { var responseBytes = Encoding.UTF8.GetBytes(response); channel.BasicPublish(exchange: "", routingKey: props.ReplyTo, basicProperties: replyProps, body: responseBytes); channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false); } }; Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } }
public void When_Creating_Group_Then_You_Are_Admin_And_Member() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("potato", "potàto"); _business.CreateGroup("FrenchFries", "Fried batons of potato", "potato"); Assert.AreEqual("potato", _business.GetGroupList().FirstOrDefault(g => g.Name == "FrenchFries")?.Administrator.Name); Assert.IsTrue(_business.GetGroupList().FirstOrDefault(g => g.Name == "FrenchFries")?.Members.Exists(m => m.Name == "potato") == true); }
public void When_Creating_With_Existing_NonEmpty_Files_Then_Loads_Correctly() { _business = new ServerBusiness(_loadGroups, _loadClients); var clients = _business.GetClientList(); var groups = _business.GetGroupList(); Assert.IsNotNull(clients); Assert.IsNotNull(groups); }
public void When_Creating_User_Then_User_Can_Login() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("Henry", "hunter2"); _business.CreateUser("Bobby", "IOnlySee*******"); Assert.IsTrue(_business.Connect("Henry", "hunter2")); Assert.IsTrue(_business.Connect("Bobby", "IOnlySee*******")); }
public override bool Execute(ServerBusiness bsn) { if (bsn != null) { return bsn.SendMessage(sendMessage); } return false; }
public override bool Execute(ServerBusiness bsn) { if (LywConfig.GetPublisher() == ProductPublisher.Local) { // 本地登陆 return(bsn.LoginAS(asHost, asPort, CallBackId, accountName, password, randomSeed, channelId, version, deviceInfo)); } else { // 平台登陆 return(bsn.LoginAS(asHost, asPort, CallBackId, accountName, password, randomSeed, channelId, version, deviceInfo, userId, channelUserId, channelCode, productCode, token)); } }
public void When_Double_Invite_Is_Sent_Then_Only_One_Is_Kept() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("soyElAdmin", "holaSombreros"); _business.CreateUser("noSoyElAdmin", "laAguaAzul"); _business.CreateGroup("LosBanditos", "¡Mira este hijo!", "soyElAdmin"); _business.SendClientGroupInvitation("soyElAdmin", "noSoyElAdmin", "LosBanditos"); _business.SendClientGroupInvitation("soyElAdmin", "noSoyElAdmin", "LosBanditos"); var notifs = _business.GetNotification("noSoyElAdmin"); Assert.IsTrue(notifs.Count == 1); }
public void When_Changing_Group_Admin_Then_Rights_Are_Swapped() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("soyElAdmin", "holaSombreros"); _business.CreateUser("noSoyElAdmin", "laAguaAzul"); _business.CreateGroup("LosBanditos", "¡Mira este hijo!", "soyElAdmin"); _business.SendClientGroupInvitation("soyElAdmin", "noSoyElAdmin", "LosBanditos"); _business.AcknowledgeInvite("noSoyElAdmin", "LosBanditos", true); Assert.AreEqual("soyElAdmin", _business.GetGroupList().FirstOrDefault(g => g.Name == "LosBanditos")?.Administrator.Name); _business.ChangeAdministratorGroup("soyElAdmin", "noSoyElAdmin", "LosBanditos"); Assert.AreEqual("noSoyElAdmin", _business.GetGroupList().FirstOrDefault(g => g.Name == "LosBanditos")?.Administrator.Name); }
public void SetUp() { // Delete last test data string rootPath = "Server Root Test"; if (Directory.Exists(rootPath)) { Directory.Delete(rootPath, true); } business = new ServerBusiness("groupSave", "clientSave", rootPath); business.CreateUser("Bob", "psw"); business.CreateGroup("A", "Desc", "Bob"); }
public void When_Request_Is_Sent_Then_Admin_Has_Notification() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("soyElAdmin", "holaSombreros"); _business.CreateUser("noSoyElAdmin", "laAguaAzul"); _business.CreateGroup("LosBanditos", "¡Mira este hijo!", "soyElAdmin"); _business.SendClientGroupRequest("noSoyElAdmin", "LosBanditos"); var notifs = _business.GetNotification("soyElAdmin"); Assert.IsTrue(notifs.Count == 1); Assert.IsTrue(notifs.FirstOrDefault()?.ActionType == ActionType.Request); Assert.IsTrue(notifs.FirstOrDefault()?.ClientName == "noSoyElAdmin"); Assert.IsTrue(notifs.FirstOrDefault()?.GroupName == "LosBanditos"); }
public override void Initialize(params object[] parameters) { if (parameters == null || parameters.Length < 3) { return; } responseTimeOut = (float)parameters[0]; brokenDelegate = (Action <string>)parameters[1]; busyDelegate = (Action <bool>)parameters[2]; busyNumber = 0; lastBusyNumber = 0; lastAddRequestTime = 0; business = new ServerBusiness(); business.Initialize(); }
public void When_Admin_Kicks_User_Then_User_Is_Removed() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("soyElAdmin", "holaSombreros"); _business.CreateUser("noSoyElAdmin", "laAguaAzul"); _business.CreateGroup("LosBanditos", "¡Mira este hijo!", "soyElAdmin"); _business.SendClientGroupInvitation("soyElAdmin", "noSoyElAdmin", "LosBanditos"); _business.AcknowledgeInvite("noSoyElAdmin", "LosBanditos", true); var group = _business.GetGroupList().FirstOrDefault(g => g.Name == "LosBanditos"); Assert.IsTrue(group?.Members.Count == 2); _business.KickUserFromGroup("soyElAdmin", "noSoyElAdmin", "LosBanditos"); Assert.IsTrue(group.Members.Count == 1); Assert.IsTrue(_business.GetGroupListForClient("noSoyElAdmin").Count == 0); }
public void When_Invite_Is_Sent_Then_Admin_Can_Reply() { _business = new ServerBusiness(GroupsSaveFile, ClientsSaveFile); _business.CreateUser("soyElAdmin", "holaSombreros"); _business.CreateUser("noSoyElAdmin", "laAguaAzul"); _business.CreateGroup("LosBanditos", "¡Mira este hijo!", "soyElAdmin"); _business.SendClientGroupRequest("noSoyElAdmin", "LosBanditos"); var notif = _business.GetNotification("soyElAdmin").FirstOrDefault(); _business.AcknowledgeRequest("soyElAdmin", notif?.ClientName, notif?.GroupName, true); var groupsForClient = _business.GetGroupListForClient(notif?.ClientName); Assert.IsTrue(groupsForClient.Count == 1); var group = groupsForClient.FirstOrDefault(); Assert.IsTrue(group != null && group.Members.Exists(m => m.Name == notif?.ClientName)); }
public bool RunExecute(ServerBusiness bsn) { if (IsExecuted) { LoggerManager.Instance.Error("Execute executed request " + ToString()); } if (IsDiscarded) { LoggerManager.Instance.Error("Execute discarded request " + ToString()); } if (IsCombined) { LoggerManager.Instance.Error("Execute combined request " + ToString()); } isExecuteSuccess = Execute(bsn); isExecuted = true; return isExecuteSuccess; }
public void TestSendingMessageFromClientToServer() { IServerBusiness business = new ServerBusiness("groupsSaveFile", "clientsSaveFile"); ServerDispatcher server = new ServerDispatcher(business, "127.0.0.1", 10000); ClientServerAccess clientLinkToServer = new ClientServerAccess("127.0.0.1", 10000); try { clientLinkToServer.CreateUser("Henry", "hunter2"); } catch (Exception) { Assert.IsTrue(true); } Assert.IsTrue(clientLinkToServer.Connect("Henry", "hunter2")); server.CloseConnection(); Thread.Sleep(1000); }
public virtual bool Execute(ServerBusiness bsn) { return false; }
public override bool Execute(ServerBusiness bsn) { return(bsn.CreateAccountAS(asHostName, asHostPort, CallBackId, accountName, accountPassword, "tttttttt", channelId, "1", deviceInfo)); }
public override bool Execute(ServerBusiness bsn) { PlayerSaveData.Destroy(); //登录成功需要使用新号的本地数据 return(bsn.LoginGS(gsHostName, gsHostPort, CallBackId, DataModelManager.Instance.LoginInfo.AccountId, area.AreaId, DataModelManager.Instance.LoginInfo.Token)); }
public void When_Creating_With_Empty_Parameters_Then_Exception() { _business = new ServerBusiness("", ""); }
public override bool Execute(ServerBusiness bsn) { return(bsn.ActiveCodeAS(asHostName, asHostPort, callBackId, accountId, activeCode)); }