public async Task OnGet_WhenRespondentDetailsAvailableInDb_PopulateModel() { var senderType = new SenderType() { SenderId = "Test1234", IsAgent = true, IsLine = false, IsPort = false }; var senderIdPort = new SenderIdPort { SenderId = "Test1234", Locode = "ABC456" }; await actualContext.SenderType.AddAsync(senderType); await actualContext.SenderIdPort.AddAsync(senderIdPort); await actualContext.SaveChangesAsync(); var result = (PageResult)await model.OnGetAsync(); Assert.IsNotNull(result); Assert.IsNotNull(model.SenderType.SenderId); Assert.IsTrue(model.SenderType.IsAgent); Assert.IsFalse(model.SenderType.IsLine); Assert.AreEqual(portFreightUsers.FirstOrDefault().SenderId, model.SenderType.SenderId); Assert.IsInstanceOfType(result, typeof(PageResult)); }
/// <summary> /// 處理傳遞訊息的控制邏輯 /// </summary> /// <param name="notifytype">enum: System, User</param> /// <param name="sendertype">enum: Email, Line</param> /// <param name="message">訊息物件</param> /// <returns></returns> public string Notify(NotifyType notifytype, SenderType sendertype, Message message) { string procResult = ""; // 判斷需產出哪一個 RefinedAbstraction 的子類別物件 switch (notifytype) { case NotifyType.System: notifier = new SystemNotifier(); break; case NotifyType.User: notifier = new UserNotifier(); break; } // 判斷需哪個實作 MessageSender 介面的實作物件來服務 // 實務上會設計如 List or Hastable 集合儲存這些實作物件,並透過 Key 來取得相對應的實作物件 switch (sendertype) { case SenderType.Email: notifier.sender = mailSender; break; case SenderType.Line: notifier.sender = lineSender; break; } // 回傳執行結果,藉此觀察使用哪一個 Notifier 子類別物件與 MessengSender 物件 procResult = notifier.Notify(message); return(procResult); }
/// <summary> /// 處理傳遞訊息的控制邏輯 /// </summary> /// <param name="notifytype">enum: System, User</param> /// <param name="sendertype">enum: Email, Line</param> /// <param name="message">訊息物件</param> /// <returns></returns> public string Notify(NotifyType notifytype, SenderType sendertype, Message message) { string procResult = ""; // 判斷需產出哪一個 RefinedAbstraction 的子類別物件 switch (notifytype) { case NotifyType.System : notifier = new SystemNotifier(); break; case NotifyType.User : notifier = new UserNotifier(); break; } // 判斷需哪個實作 MessageSender 介面的實作物件來服務 // 實務上會設計如 List or Hastable 集合儲存這些實作物件,並透過 Key 來取得相對應的實作物件 switch (sendertype) { case SenderType.Email : notifier.sender = mailSender; break; case SenderType.Line : notifier.sender = lineSender; break; } // 回傳執行結果,藉此觀察使用哪一個 Notifier 子類別物件與 MessengSender 物件 procResult = notifier.Notify(message); return procResult; }
public TransferEvent(string operationId, string transactionHash, string amount, string tokenAddress, string fromAddress, string toAddress, string blockHash, ulong blockNumber, SenderType senderType, EventType eventType, WorkflowType workflowType, DateTime detectedTime) { OperationId = operationId; DetectedTime = detectedTime; TransactionHash = transactionHash; Amount = amount; TokenAddress = tokenAddress; FromAddress = fromAddress; ToAddress = toAddress; SenderType = senderType; EventType = eventType; BlockHash = blockHash; BlockNumber = blockNumber; WorkflowType = workflowType; }
internal void Flush() { this.Handler = null; this.ChannelHanderContext = null; this.MessageId = 0; this.RpcId = 0; this.SenderType = SenderType.NormalSender; }
public void ConvertSDKUnrecognizedSenderTypeToAPIUnknownValue() { apiSenderType1 = "NEWLY_ADDED_SENDER_TYPE"; SenderType unrecognizedSenderType = SenderType.valueOf(apiSenderType1); string acutalAPIValue = new SenderTypeConverter(unrecognizedSenderType).ToAPISenderType(); Assert.AreEqual(apiSenderType1, acutalAPIValue); }
internal void SetContext(NetworkHandler handler, IChannelHandlerContext handerContext, int messageId = 0 , int rpcId = 0, SenderType senderType = SenderType.NormalSender) { this.Handler = handler; this.ChannelHanderContext = handerContext; this.MessageId = messageId; this.RpcId = rpcId; this.SenderType = senderType; }
public Message(ElementType cat, State traverse, int action, SenderType senderType, int ownerId, object data) { this.Category = cat; this.Data = data; this.Traverse = traverse; this.Action = action; this.OwnerId = ownerId; this.SenderType = senderType; }
public static INotificationSender GetSenderProviderFactory(SenderType senderType) { switch (senderType) { case SenderType.Email: return(new EmailSender()); } return(null); }
private SenderType AddSenderType(SenderType senderType) { if (senderType != default) { _senderTypes.Add(senderType); _senderTypes.TryGetValue(senderType, out senderType); } return(senderType); }
public void whenBuildingSenderTypeWithAPIValueREGULARThenREGULARSenderTypeIsReturned() { string expectedSDKValue = "REGULAR"; SenderType classUnderTest = SenderType.valueOf("REGULAR"); String actualSDKValue = classUnderTest.getSdkValue(); Assert.AreEqual(expectedSDKValue, actualSDKValue); }
public void TestSenderType() { foreach (SenderType senderType in SenderType.Values()) { Assert.IsNotNull(senderType.ToString()); Assert.IsNotEmpty(senderType.ToString()); } Assert.AreEqual(0, (int)SenderType.REGULAR); Assert.AreEqual("MANAGER", (string)SenderType.MANAGER); Assert.AreEqual("MANAGER", SenderType.MANAGER.GetName()); }
public void RoutingTyping(Guid relationId, bool Flag, SenderType sender) { if (sender == SenderType.Friend) { Clients.OthersInGroup(relationId + "Member").typingIndicator(new { FlagIndicator = Flag, RelationId = relationId }); } else { Clients.OthersInGroup(relationId + "Friend").typingIndicator(new { FlagIndicator = Flag, RelationId = relationId }); } }
public void whenBuildingSenderTypeWithUnknownAPIValueThenUNRECOGNIZEDSenderTypeIsReturned() { string expectedSDKValue = "UNRECOGNIZED"; SenderType classUnderTest = SenderType.valueOf("ThisSenderTypeDoesNotExistINSDK"); String actualSDKValue = classUnderTest.getSdkValue(); Assert.AreEqual(expectedSDKValue, actualSDKValue); }
/// <summary> /// Initializes a new instance of the <see cref="Message"/> class. /// </summary> /// <param name="sender">Id of the sender, use -1 to be an undentified sender</param> /// <param name="receiver">Reciever ID, use -1 to send to a Tag group</param> /// <param name="tag">Tag (used to send to a group of entities), if the message will be send to just one reciver, use null here</param> /// <param name="pri">Priority</param> /// <param name="timetodeliver">Time to send the message in MILISECONDS( Use 0 to send in THIS frame and -1 to send NOW)</param> /// <param name="type">Message Type; The engine DONT use this field for NOTHING, its for user control</param> /// <param name="Content">Message Content</param> /// <param name="cod">Message Code, The engine DONT use this field, its for user control</param> public Message(long sender, long receiver, string tag, Priority pri, int timetodeliver, SenderType type, Object Content, string cod) { this.sender = sender; this.receiver = receiver; this.tag = tag; this.prioridade = pri; this.timetodeliver = timetodeliver; this.type = type; this.content = Content; this.cod = cod; }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { SenderType senderType = (SenderType)validationContext.ObjectInstance; var containerType = validationContext.ObjectInstance.GetType(); if (!senderType.IsAgent && !senderType.IsLine && !senderType.IsPort) { return(new ValidationResult(GetErrorMessage())); } return(ValidationResult.Success); }
public ISenderAgent Resolve(SenderType type) { switch (type) { case SenderType.Telegram: return((ISenderAgent)(_serviceProvider.GetService(typeof(TelegramSenderAgent)))); case SenderType.Sms: return((ISenderAgent)(_serviceProvider.GetService(typeof(TwilioSmsSenderAgent)))); default: throw new InvalidOperationException("Unsupported sender type"); } }
public ShortMessage(IMessageSender messageSender) { _messageSender = messageSender; _messageSentCount = 0; if (messageSender is EmailMessageSender) { _senderType = SenderType.Email; } else if (messageSender is SMSMessageSender) { _senderType = SenderType.SMS; } }
public static bool IsSender(this ISender sender, SenderType type) { switch (type) { case SenderType.CONSOLE: return sender is ConsoleSender && !(sender is RemoteConsole.RConSender); case SenderType.PLAYER: return sender is Player; case SenderType.RCON: return sender is RemoteConsole.RConSender; default: throw new InvalidOperationException("No such sender."); } }
public void AddTask(TaskItem item, SenderType sender) { if (sender == SenderType.SyncService) { // using dispatcher because Tasks object will be updated in the UI thread from sync service, hich runs in background dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { this.Tasks.Add(item); }); } else { // we need to add sorted, so we find the position where to insert the element in the UI int index; switch (this.ParentList.SortBy) { case ListSortType.DueDate: index = this.Tasks.Select(t => t.CreatedOn).ToList().BinarySearch(item.DueDate); break; case ListSortType.Title: index = this.Tasks.Select(t => t.Title).ToList().BinarySearch(item.Title); break; default: index = this.Tasks.Select(t => t.CreatedOn).ToList().BinarySearch(item.CreatedOn); break; } if (index < 0) { index = ~index; } this.Tasks.Insert(index, item); this._syncService.SendUpdate(new SyncMessage { Type = UpdateType.Add, Timestamp = item.CreatedOn, Data = new TaskItemUpdate { Item = item } }); } this.taskService.TaskAdd(item); }
public static bool IsSender(this ISender sender, SenderType type) { switch (type) { case SenderType.CONSOLE: return sender is ConsoleSender;// && !(sender is RemoteConsole.RConSender); #if Full_API case SenderType.PLAYER: return sender is Terraria.Player; #endif //case SenderType.RCON: // return sender is RemoteConsole.RConSender; default: throw new InvalidOperationException("No such sender."); } }
// Neeed Optimization public void RoutingImageMessage(Guid relationId, string path, SenderType sender) { var context = GlobalHost.ConnectionManager.GetHubContext <MessagesHub>(); if (_unitOfWork.RelationsRepository.GetRelation(relationId) != null) { if (sender == SenderType.Friend) { context.Clients.Group(relationId + "Member").recieveMessage(relationId, path, MessageType.ImageMessage); } else { context.Clients.Group(relationId + "Friend").recieveMessage(relationId, path, MessageType.ImageMessage); } } EventsTracerManager.AddEvent(EventType.MemberMessage); }
public override ISender Create(SenderType senderType) { switch (senderType) { case SenderType.Sms: return(new SMSSender()); case SenderType.Email: return(new EmailSender()); case SenderType.Push: return(new PushSender()); default: throw new ArgumentOutOfRangeException(nameof(senderType), senderType, "Enter a valid argument."); } }
public static bool IsSender(this ISender sender, SenderType type) { switch (type) { case SenderType.CONSOLE: return(sender is ConsoleSender); // && !(sender is RemoteConsole.RConSender); #if Full_API case SenderType.PLAYER: return(sender is Terraria.Player); #endif //case SenderType.RCON: // return sender is RemoteConsole.RConSender; default: throw new InvalidOperationException("No such sender."); } }
public static bool IsSender(this ISender sender, SenderType type) { switch (type) { case SenderType.CONSOLE: return(sender is ConsoleSender && !(sender is RemoteConsole.RConSender)); case SenderType.PLAYER: return(sender is Player); case SenderType.RCON: return(sender is RemoteConsole.RConSender); default: throw new InvalidOperationException("No such sender."); } }
public virtual ISender Create(SenderType senderType) { switch (senderType) { case SenderType.Sms: return(new SMSSender()); case SenderType.Email: return(new EmailSender()); case SenderType.Push: return(new PushSender()); default: throw new ArgumentOutOfRangeException(nameof(senderType), senderType, "Informe um argumento valido"); } }
public static ISender Get(SenderType type) { ISender sender = null; switch (type) { case SenderType.Irc: sender = new IrcSender(); break; case SenderType.Email: default: sender = new EmailSender(); break; } return(sender); }
private void AssignDataToInput(SenderType senderType) { RespondentVM.PortList.Clear(); foreach (var senderPort in senderType.SenderIdPort) { SenderPort port = new SenderPort { Id = Guid.NewGuid(), SenderId = senderPort.SenderId, Locode = senderPort.Locode, PortName = _context.GlobalPort.Where(s => s.Locode == senderPort.Locode) .Select(s => s.PortName).FirstOrDefault() }; RespondentVM.SenderId = senderPort.SenderId; RespondentVM.PortList.Add(port); } ; }
public Sender(string title, string forname1, string forname2, string surname, string telephone, string mobile, string email, string addressline1, string addressline2, string addressline3, string postcode, string password) { this._type = SenderType.Contractor; // always idividual // this._alTestCredentials = new ArrayList(); this._title = title; this._forName1 = forname1; this._forName2 = forname2; this._surName = surname; this._telephone = telephone; this._mobile = mobile; this._email = email; this._addressLine1 = addressline1; this._addressLine2 = addressline2; this._addressLine3 = addressline3; this._postCode = postcode; //this._senderId = senderId; this._senderPassword = password; }
public async Task OnLogin_WhenProfileComplete_RedirectToDashboard() { var portFreightUser = new PortFreightUser() { UserName = "******", Email = "*****@*****.**", PasswordHash = "TestTest1!", SenderId = "T12345" }; portFreightUsersList = new List <PortFreightUser>(); portFreightUsersList.Add(portFreightUser); loginModel.Input = new LoginModel.InputModel { Email = portFreightUser.Email, Password = portFreightUser.PasswordHash, RememberMe = true }; mockfakeSignInManager.Setup(x => x.PasswordSignInAsync(loginModel.Input.Email, loginModel.Input.Password, loginModel.Input.RememberMe, true)).ReturnsAsync(Microsoft.AspNetCore.Identity.SignInResult.Success); mockUserManager.Setup(u => u.FindByEmailAsync(It.IsAny <string>())).ReturnsAsync(portFreightUsersList.FirstOrDefault()); var ContactDetails = new ContactDetails { SenderId = "T12345" }; await actualContext.ContactDetails.AddAsync(ContactDetails); actualContext.SaveChanges(); var SenderType = new SenderType { SenderId = "T12345" }; await actualContext.SenderType.AddAsync(SenderType); actualContext.SaveChanges(); var result = (RedirectToPageResult)await loginModel.OnPostAsync(); Assert.IsNotNull(result); Assert.AreEqual("/Dashboard", result.PageName); Assert.IsInstanceOfType(result, typeof(RedirectToPageResult)); }
public void RoutingMessage(Guid relationId, string message, SenderType sender) { if (_unitOfWork.RelationsRepository.GetRelation(relationId) != null) { string temp = HttpUtility.HtmlEncode(message); if (sender == SenderType.Friend) { Clients.OthersInGroup(relationId + "Member").recieveMessage(relationId, temp, MessageType.TextMessage); } else { Clients.OthersInGroup(relationId + "Friend").recieveMessage(relationId, temp, MessageType.TextMessage); } _unitOfWork.MessagesRepository.AddMessage(new Message { relation_id = relationId, Type = MessageType.TextMessage, MessageData = temp, Date = DateTime.UtcNow, Sender = sender }); _unitOfWork.Complete(); } EventsTracerManager.AddEvent(EventType.MemberMessage); }
/// <summary> /// Generate a new, random message from a given senderType for a given scenario /// </summary> /// <param name="mType">The type of message to return, AKA the scenario (conversation, battle, etc.)</param> /// <param name="sType">The type of sender for this message (Mom, Dad, Rival, etc.)</param> /// <returns>A random message with the given constraints</returns> public static Message GetMessage(MessageType mType, SenderType sType) { //this is still kinda ugly //iterate through the whole list to get List <Message> tempList = new List <Message>(); for (int i = 0; i < texts.Count; i++) { if (mType == texts[i].getMessageType() && sType == texts[i].getSenderType()) { tempList.Add(texts[i]); } } //need to specify UnityEngine here because we are using the "System" library int rand = UnityEngine.Random.Range(0, tempList.Count); //grab a random entry and return it return(tempList[rand]); }
public async Task OnPost_WhenEditingSenderType_ReturnsARedirectToPageResult() { var optionsBuilder = new DbContextOptionsBuilder <PortFreightContext>() .UseInMemoryDatabase("InMemoryDb") .Options; var context = new PortFreightContext(optionsBuilder); var senderType = new SenderType() { SenderId = "Test5678", IsAgent = true, IsLine = false, IsPort = false }; await context.SenderType.AddAsync(senderType); await context.SaveChangesAsync(); model.SenderIdPort = new SenderIdPort { SenderId = "Test5678", Locodes = new List <string> { "AAA123", "ABC456" } }; model.SenderType = new SenderType { SenderId = "Test5678", IsAgent = true, IsLine = false, IsPort = true }; var result = (RedirectToPageResult)await model.OnPostAsync(); Assert.IsNotNull(result); Assert.AreEqual("/Dashboard", result.PageName); Assert.IsInstanceOfType(result, typeof(RedirectToPageResult)); }
/// <summary> /// set the header. /// </summary> /// <param name="header"> /// The header. /// </param> /// <param name="beans"> /// The beans. /// </param> /// <param name="receivers"> /// The receivers. /// </param> public static void SetHeader(BaseHeaderType header, ISdmxObjects beans, params string[] receivers) { header.ID = "IDREF" + refNumber; refNumber++; header.Test = false; header.Prepared = DateTime.Now; var sender = new SenderType(); header.Sender = sender; string senderId; if (beans != null && beans.Header != null && beans.Header.Sender != null) { // Get header information from the supplied beans senderId = beans.Header.Sender.Id; } else { // Get header info from HeaderHelper senderId = HeaderHelper.Instance.SenderId; } sender.id = senderId; if (ObjectUtil.ValidArray(receivers)) { /* foreach */ foreach (string currentReviever in receivers) { var receiver = new PartyType(); header.Receiver.Add(receiver); receiver.id = currentReviever; } } else { var receiver0 = new PartyType(); header.Receiver.Add(receiver0); receiver0.id = HeaderHelper.Instance.ReceiverId; } }
/// <summary> /// Initializes a new instance of the <see cref="SystemRecieverMessage"/> class. /// </summary> public SystemRecieverMessage(SenderType AcceptableMessagesTypes = SenderType.SYSTEM) { this.AcceptableMessagesTypes = AcceptableMessagesTypes; EntityMapper.getInstance().AddEntity(this); }
public bool HandleThisMessageType(SenderType type) { return true; }
/// <summary> /// Initializes a new instance of the <see cref="PartyCore"/> class. /// </summary> /// <param name="senderType"> /// The sender type. /// </param> public PartyCore(SenderType senderType) : this() { this.id = senderType.id; if (ObjectUtil.ValidCollection(senderType.Name)) { foreach (Name tt in senderType.Name) { this._name.Add(new TextTypeWrapperImpl(tt, null)); } } if (ObjectUtil.ValidCollection(senderType.Contact)) { foreach (ContactType contactType in senderType.Contact) { this.contacts.Add(new ContactCore(contactType)); } } this.timeZone = senderType.Timezone; this.Validate(); }
/// <summary> /// Handles a message from determined sender type. /// </summary> /// <param name="type">Sender type.</param> /// <returns></returns> public bool HandleThisMessageType(SenderType type) { return type == AcceptableMessagesTypes; }
public MessageReceivedEventArgs(ChatMessage msg, SenderType sender, Player player) { Message = msg; Sender = sender; Player = player; }
public bool HandleThisMessageType(SenderType type) { return type == SenderType.EVENT; }