public void Should_GetMessageFunction_Return_SingleMessage() { //Arrange var _mockRepo = new Mock <IRepositoryWrapper>(); var _mockPrincipal = new Mock <IUserClaimsPrincipal>(); var _mockLogger = new Mock <ILoggerManager>(); var message = new MessageDetailVM() { Id = 1, UserName = "******", Text = "Hi There.", }; _mockRepo.Setup(x => x.Message.GetMessageWithDetailByIdAsync(message.Id)).ReturnsAsync(message); _mockPrincipal.Setup(x => x.GetUserName(It.IsAny <ClaimsPrincipal>())).Returns("admin"); _mockRepo.Setup(x => x.User.GetUserByUserNameAsync("admin")).ReturnsAsync(1); var controller = new MessageController(_mockRepo.Object, _mockLogger.Object, _mockPrincipal.Object); //Act var actual = controller.Get(message.Id); //Assert var actualUser = ((MessageDetailVM)(((OkObjectResult)actual.Result).Value)); Assert.Same(message, actualUser); Assert.Equal(message.Id, actualUser.Id); Assert.Equal(message.Text, actualUser.Text); }
public async Task SendMessage_ShouldReturnNotFoundResult_WhenRecipientDoesNotExist() { // Arrange SendMessageBody body = new SendMessageBody { RecipientId = 4314, HtmlContent = "hello world" }; _mediatorMock .Setup(m => m.Send(It.IsAny <RecipientExistsQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(false); MessageController controller = new MessageController(null, _mediatorMock.Object); // Act ActionResult <ChatMessageResource> response = await controller.SendMessage(body); // Assert NotFoundObjectResult result = Assert.IsType <NotFoundObjectResult>(response.Result); ErrorResource error = Assert.IsType <ErrorResource>(result.Value); Assert.NotNull(error); Assert.Equal(StatusCodes.Status404NotFound, error.StatusCode); }
void Start() { single = this; _canvasesWaiting = 0; _pleaseWaitCanvas.enabled = false; _errorCanvas.enabled = false; }
public async Task EditMessage_ShouldReturnNotFoundResult_WhenMessageDoesNotExist() { // Arrange const int messageId = 1; EditMessageBody body = new EditMessageBody { HtmlContent = "<p>hello world</p>" }; _mediatorMock .Setup(m => m.Send(It.IsAny <MessageExistsQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(false); MessageController controller = new MessageController(null, _mediatorMock.Object); // Act ActionResult response = await controller.EditMessage(messageId, body); // Assert NotFoundObjectResult result = Assert.IsType <NotFoundObjectResult>(response); ErrorResource error = Assert.IsType <ErrorResource>(result.Value); Assert.NotNull(error); Assert.Equal(StatusCodes.Status404NotFound, error.StatusCode); }
public async Task DeleteMessage_ShouldReturnForbiddenResult_WhenTheUserIsNotTheAuthorOfTheMessage() { // Arrange const int messageId = 1; _mediatorMock .Setup(m => m.Send(It.IsAny <MessageExistsQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); _mediatorMock .Setup(m => m.Send(It.IsAny <IsAuthorOfMessageQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(false); MessageController controller = new MessageController(null, _mediatorMock.Object); // Act ActionResult response = await controller.DeleteMessage(messageId); // Assert ObjectResult result = Assert.IsType <ObjectResult>(response); ErrorResource error = Assert.IsType <ErrorResource>(result.Value); Assert.NotNull(error); Assert.Equal(StatusCodes.Status403Forbidden, error.StatusCode); }
public async void TestGetUserInboxes() { var options = new DbContextOptionsBuilder <MessageContext>() .UseInMemoryDatabase(databaseName: "p3MessageService") .Options; using (var context = new MessageContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Repo r = new Repo(context, new NullLogger <Repo>()); Mapper map = new Mapper(); Logic logic = new Logic(r, map, new NullLogger <Repo>()); MessageController messageController = new MessageController(logic, null); var userInbox = new UserInbox { UserID = "23654345", MessageID = Guid.NewGuid(), IsRead = false }; r.UserInboxes.Add(userInbox); await r.CommitSave(); var getUserInboxes = await messageController.GetUserInboxes(userInbox.UserID); Assert.NotNull(getUserInboxes); } }
void Start() { myStart = transform.position; otherStart = helpfulBartender.transform.position + Vector3.down * 10; otherEnd = helpfulBartender.transform.position; helpfulBartender.transform.position = otherStart; GameConductor.AddScheduleCallback((int hour, int min) => { if (hour == 11 && min == 0) { ResetState(); } else if (hour == 12 && min == 50 && GameConductor.IsMaidAQuitter) { HelpDrunk(); } else if (hour == 2 && min == 0 && !GameConductor.IsOblexRevealed) { GameConductor.FreezePlayer(); MessageController.AddMessage("(you hear the bartender's voice)"); MessageController.AddMessage("Oy! Last call for drinks! The show's over!"); MessageController.AddMessage("Nothing more to see!", postAction: () => GameConductor.UnfreezePlayer()); } }); }
public async void GetSegmentedInformation(Message[] messages) { // Arrange var mock = new Mock <IMessageRepository>(); int size = 3, index = 2; mock.Setup(rep => rep.GetAllMessagesAsync(size, index)) .Returns(() => Task <IEnumerable <Message> > .Run(() => { List <Message> ls = new List <Message>(); ls.Add(messages[2]); ls.Add(messages[3]); return(ls.AsEnumerable <Message>()); })); mock.Setup(rep => rep.LongCountAsync()).Returns(Task <Message> .Run(() => messages.LongCount())); MessageController controller = new MessageController(mock.Object); // Act OkObjectResult result = await controller.GetAllMessages( size : size, index : index) as OkObjectResult; SegmentedItems <Message> model = result?.Value as SegmentedItems <Message>; // Assert Assert.Equal(messages.LongCount(), model?.Count); Assert.Equal(index, model?.Index); Assert.Equal(size, model?.Size); }
public async void GetSegmentedMessagesOk(Message[] messages) { // Arrange var mock = new Mock <IMessageRepository>(); int size = 2, index = 2; mock.Setup(rep => rep.GetAllMessagesAsync(size, index)) .Returns(() => Task <IEnumerable <Message> > .Run(() => { List <Message> ls = new List <Message>(); ls.Add(messages[2]); ls.Add(messages[3]); return(ls.AsEnumerable <Message>()); })); mock.Setup(rep => rep.LongCountAsync()).Returns(() => Task <long> .Run(() => 2L)); MessageController controller = new MessageController(mock.Object); // Act OkObjectResult result = await controller.GetAllMessages( size : size, index : index) as OkObjectResult; SegmentedItems <Message> model = result?.Value as SegmentedItems <Message>; // Assert Assert.Equal((int?)HttpStatusCode.OK, result?.StatusCode); Assert.True(model?.Count == 2); Assert.Equal(messages[2], model?.Items?.ToArray <Message>()[0], Comparer.Get <Message>((m1, m2) => m1.Id == m2.Id)); Assert.Equal(messages[3], model?.Items?.ToArray <Message>()[1], Comparer.Get <Message>((m1, m2) => m1.Id == m2.Id)); }
/// <summary> /// Starts process of receiving messages from server. /// </summary> /// <param name="planningPokerController">Instance of <see cref="PlanningPokerController"/> to send messages to.</param> /// <returns><see cref="IDisposable"/> object that can be used to stop receiving of messages.</returns> public IDisposable StartReceiving(PlanningPokerController planningPokerController) { var result = new MessageController(planningPokerController, _planningPokerClient); result.StartReceiving(); return(result); }
public void DeleteMessage(User user) { Console.Clear(); Console.WriteLine("You can delete messages that only you have sent"); Console.WriteLine(""); MessageController messageController = new MessageController(); var messagesSended = messageController.RetrieveMessagesBySender(user.Id); if (messagesSended.Count == 0) { Console.WriteLine("You do not have messages sent"); Console.WriteLine("Press something to return"); Console.ReadKey(); return; } foreach (var item in messagesSended) { Console.WriteLine( $"MessageId: {item.MessageId}, " + $"DateOfSubmission: {item.DateOfSubmission.ToString(CultureInfo.GetCultureInfo("el-GR"))}, " + $"messageData: {item.MessageData}, " + $"receiver: {item.Receiver.UserName},"); } bool value = true; int checkId; List <int> messagesId = messagesSended.Select(x => x.MessageId).ToList(); do { Console.WriteLine(""); Console.WriteLine("Choose the messageId of the message you want to delete or press 0 to return back"); bool success = int.TryParse(Console.ReadLine(), out checkId); if (success) { if (checkId == 0) { return; } if (messagesId.Contains(checkId)) { value = false; } } } while (value); try { messageController.DeleteMessage(checkId); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Clear(); Console.WriteLine("Message Deleted"); Console.WriteLine("Press something to exit"); Console.ReadKey(); }
public void btnSave_Click(object sender, EventArgs e) { string displayImagePath = ""; string strImageName = ""; if (fileDisplayImage.HasFile) { string filExtention = ""; filExtention = fileDisplayImage.FileName.Substring(fileDisplayImage.FileName.Length - 4); filExtention = filExtention.ToLower(); if ((filExtention != ".gif") && (filExtention != ".jpg") && (filExtention != "jpeg") && (filExtention != ".bmp") && (filExtention != ".png")) { lblMessage.Text = "Please select gif/jpg/bmp/png image"; lblMessage.ForeColor = System.Drawing.Color.OrangeRed; return; } strImageName = Guid.NewGuid().ToString().GetHashCode().ToString() + "-" + System.IO.Path.GetFileName(fileDisplayImage.FileName); displayImagePath = Server.MapPath("~/UserFile/Slider/") + strImageName; fileDisplayImage.SaveAs(displayImagePath); } new bllSlider().InsertUpdate(ID, strImageName, tbxDescription.Text); new bllAudit().Insert("Setup", "InsertUpdate Slider", "Image Name: " + strImageName, User.Identity.Name); lblMessage.ForeColor = System.Drawing.Color.Green; MessageController.Show(MessageCode._SaveSucceeded, MessageType.Information, Page); ClearAll(); }
public void Start() { Show_BuyUnitText(); scriptManager = GameObject.Find("ScriptManager").GetComponent<ScriptManager>(); messageController = scriptManager.messageController; }
// Use this for initialization void Start () { danceMoves = new ArrayList (); woowee = wooweeObject.GetComponent<WooeeController> (); messageController = messageObject.GetComponent<MessageController> (); comboEffect = GetComponentInChildren<ComboEffect>(); startingPosition = this.transform.position; }
public void Should_DeleteExistMessageMockFunction_With_Return_NotFound() { //Arrange var message = new Message() { Id = 1, Text = "Update Message", UserId = 1, }; var _mockRepo = new Mock <IRepositoryWrapper>(); var _mockPrincipal = new Mock <IUserClaimsPrincipal>(); var _mockLogger = new Mock <ILoggerManager>(); _mockRepo.Setup(x => x.Message.DeleteMessageAsync(message)); _mockRepo.Setup(x => x.Message.GetMessageByIdAsync(5)).ReturnsAsync(new Message()); _mockPrincipal.Setup(x => x.GetUserName(It.IsAny <ClaimsPrincipal>())).Returns("admin"); _mockRepo.Setup(x => x.User.GetUserByUserNameAsync("admin")).ReturnsAsync(1); var controller = new MessageController(_mockRepo.Object, _mockLogger.Object, _mockPrincipal.Object); //Act var actual = controller.Delete(5); var actualResult = ((NotFoundObjectResult)actual.Result); //Assert Assert.Same(typeof(NotFoundObjectResult), actualResult.GetType()); Assert.Equal("Message not found.", (((ResponseVM)actualResult.Value).Title)); }
protected void btnSaveAll_Click(object sender, EventArgs e) { CobBacInfo.Save(); string BaNo = Session["ArmyNo"] as string; if (BaNo != null) { comMsn.SaveMNS(); dipState.SaveDiscipState(); mdcl.Save(); AprInfr.Save(); SpecialQualification.SaveSpecialQualification(); cors.InsertUpdateCourse(); cdre.InsertUpdateCadre(); service.InsertUpdateComService(); nok1.InsertUpdateNOK(); rmk.InsertUpdateRemrk(); MessageController.Show("Saved successfully.", MessageType.Information, Page); TabContainer1.ActiveTabIndex = 0; CobBacInfo.Clear(); ClearAllGrid(); Session["ArmyNo"] = null; tbxRnk.Text = ""; tbxName.Text = ""; tbxArmsNo.Text = ""; namePnl.Visible = false; } else { MessageController.Show("First save basic information.", MessageType.Warning, Page); } }
public async void TestGetRecipientList() { var options = new DbContextOptionsBuilder <MessageContext>() .UseInMemoryDatabase(databaseName: "p3MessageService") .Options; using (var context = new MessageContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Repo r = new Repo(context, new NullLogger <Repo>()); Mapper map = new Mapper(); Logic logic = new Logic(r, map, new NullLogger <Repo>()); MessageController messageController = new MessageController(logic, null); var recipientList = new RecipientList { RecipientListID = Guid.NewGuid(), RecipientID = "625325433" }; r.RecipientLists.Add(recipientList); await r.CommitSave(); var getRecipientList = await messageController.GetRecipientList(recipientList.RecipientListID); Assert.NotNull(getRecipientList); } }
public MessageControllerTests() { sessionService = new Mock <ISessionService>(); messageRepository = new Mock <IMessageRepository>(); subject = new MessageController(messageRepository.Object, sessionService.Object); }
public async void TestGetMessagesBySenderById() { var options = new DbContextOptionsBuilder <MessageContext>() .UseInMemoryDatabase(databaseName: "p3LeagueService") .Options; using (var context = new MessageContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Repo r = new Repo(context, new NullLogger <Repo>()); Mapper map = new Mapper(); Logic logic = new Logic(r, map, new NullLogger <Repo>()); MessageController messageController = new MessageController(logic, null); var message = new Message { MessageID = Guid.NewGuid(), SenderID = "12345", RecipientListID = Guid.NewGuid(), SentDate = DateTime.Now, MessageText = "Hello this is a text!!" }; r.Messages.Add(message); await r.CommitSave(); var getMessagesBySenderById = await messageController.GetMessagesBySenderById(message.SenderID); Assert.NotNull(getMessagesBySenderById); } }
public void GetMessagesMassageLengthTest() { var mockService = new MockTwitterService(); var controller = new MessageController(mockService); var m = new MesageSubmitModel { //257 symbols, allowed 256 Message = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has surv", UserName = "******" }; controller.Configuration = new HttpConfiguration(); controller.Validate(m); var result = controller.AddMessage(m); Assert.IsInstanceOfType(result, typeof(InvalidModelStateResult)); var item = ((InvalidModelStateResult)result).ModelState; // Assert Assert.IsNotNull(item); Assert.IsNotNull(item["Message"]); Assert.IsTrue(item["Message"].Errors.Count > 0); }
public void Should_DeleteMessageMockFunction_With_Return_SuccessWithNoCntent() { //Arrange var message = new Message() { Id = 1, Text = "Message", UserId = 1, }; var _mockRepo = new Mock <IRepositoryWrapper>(); var _mockPrincipal = new Mock <IUserClaimsPrincipal>(); var _mockLogger = new Mock <ILoggerManager>(); _mockRepo.Setup(x => x.Message.DeleteMessageAsync(message)); _mockRepo.Setup(x => x.Message.GetMessageByIdAsync(1)).ReturnsAsync(message); _mockPrincipal.Setup(x => x.GetUserName(It.IsAny <ClaimsPrincipal>())).Returns("admin"); _mockRepo.Setup(x => x.User.GetUserByUserNameAsync("admin")).ReturnsAsync(1); var controller = new MessageController(_mockRepo.Object, _mockLogger.Object, _mockPrincipal.Object); //Act var actual = controller.Delete(1); var actualResult = ((NoContentResult)actual.Result); //Assert Assert.Same(typeof(NoContentResult), actualResult.GetType()); }
void TalkToPlayer() { MessageController.SetLookTarget(transform); if (!GameOrchestrator.Instance.HasLoveLetter && !GameOrchestrator.Instance.DeliveredLoveLetter) { MessageController.AddMessage("Great day for a sail, innit?"); MessageController.AddMessage("Lookin' forward to the fire festival?"); } else if (GameOrchestrator.Instance.HasLoveLetter) { GameOrchestrator.Instance.HasLoveLetter = false; GameOrchestrator.Instance.DeliveredLoveLetter = true; MessageController.AddMessage("Oh, this is from that lass over on the shoreline?"); MessageController.AddMessage("..."); MessageController.AddMessage("Y'know, I have eyes for her too! Mate, this is great news!"); MessageController.AddMessage("It makes me so happy, I wanna do a jig!"); MessageController.AddMessage("You learned the HAPPY JIG! Share the excitement!"); GameOrchestrator.Instance.HasHappyJig = true; } else { MessageController.AddMessage("Yo ho, YOLO a pirate's life for me."); } }
public async Task EditMessage_ShouldUpdateTheMessagesContent() { // Arrange const int messageId = 1; EditMessageBody body = new EditMessageBody { HtmlContent = "<p>hello world</p>" }; _mediatorMock .Setup(m => m.Send(It.IsAny <MessageExistsQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); _mediatorMock .Setup(m => m.Send(It.IsAny <IsAuthorOfMessageQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); _mediatorMock .Setup(m => m.Send(It.IsAny <EditMessageCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(Unit.Value); MessageController controller = new MessageController(null, _mediatorMock.Object); // Act ActionResult response = await controller.EditMessage(messageId, body); // Assert Assert.IsType <NoContentResult>(response); _mediatorMock.Verify(m => m.Send(It.IsAny <EditMessageCommand>(), It.IsAny <CancellationToken>()), Times.AtLeastOnce); }
public void GetHelloWorldTest() { MessageController messageController = new MessageController(); var message = messageController.GetHelloWorld(); Assert.Equals("Hello World", message); }
public async Task DeleteMessage_ShouldDeleteMessage_AndreturnNoContentResult_WhenTheUserIsTheAuthorOfTheMessage() { // Arrange const int messageId = 1; _mediatorMock .Setup(m => m.Send(It.IsAny <MessageExistsQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); _mediatorMock .Setup(m => m.Send(It.IsAny <IsAuthorOfMessageQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); _mediatorMock .Setup(m => m.Send(It.IsAny <DeleteMessageCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(Unit.Value); MessageController controller = new MessageController(null, _mediatorMock.Object); // Act ActionResult response = await controller.DeleteMessage(messageId); // Assert Assert.IsType <NoContentResult>(response); _mediatorMock.Verify(m => m.Send(It.IsAny <DeleteMessageCommand>(), It.IsAny <CancellationToken>()), Times.Once); }
public async Task SeenHashShouldReturnStoredMessage() { var hash = "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"; var dto = new HashDto() { Hash = hash, Value = "foo" }; var repo = new Mock <IServiceRepository>(); repo.Setup(r => r.HashExistsAsync(hash)).ReturnsAsync(true); repo.Setup(r => r.FindHashAsync(hash)).ReturnsAsync(dto); var mapper = this.GetConfiguredMapper(); var logger = Mock.Of <ILogger <MessageController> >(); var controller = new MessageController(repo.Object, mapper, logger); var response = await controller.GetMessage(hash); var objectResult = Assert.IsType <OkObjectResult>(response.Result); var result = Assert.IsType <MessageResponseModel>(objectResult.Value); Assert.Equal("foo", result.Message); }
public async Task SendMessage_ShouldReturnForbiddenResult_WhenUserTriesMessagingHimself() { // Arrange SendMessageBody body = new SendMessageBody { RecipientId = 1, HtmlContent = "hello world" }; _mediatorMock .Setup(m => m.Send(It.IsAny <RecipientExistsQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); _mediatorMock .Setup(m => m.Send(It.IsAny <IsOwnRecipientQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); MessageController controller = new MessageController(null, _mediatorMock.Object); // Act ActionResult <ChatMessageResource> response = await controller.SendMessage(body); // Assert ObjectResult result = Assert.IsType <ObjectResult>(response.Result); ErrorResource error = Assert.IsType <ErrorResource>(result.Value); Assert.NotNull(error); Assert.Equal(StatusCodes.Status403Forbidden, error.StatusCode); }
public async Task InvalidHashShouldGenerateBadRequestResult() { var repo = Mock.Of <IServiceRepository>(); var mapper = Mock.Of <IMapper>(); var logger = Mock.Of <ILogger <MessageController> >(); var controller = new MessageController(repo, mapper, logger); var response = await controller.GetMessage(string.Empty); var objectResult = Assert.IsType <BadRequestObjectResult>(response.Result); Assert.IsType <ErrorResult>(objectResult.Value); // Hash of length 63 characters. response = await controller.GetMessage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); objectResult = Assert.IsType <BadRequestObjectResult>(response.Result); Assert.IsType <ErrorResult>(objectResult.Value); // Hash of length 65 characters response = await controller.GetMessage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); objectResult = Assert.IsType <BadRequestObjectResult>(response.Result); Assert.IsType <ErrorResult>(objectResult.Value); }
public void Should_UpdateEmptyMessageMockFunction_With_Return_BadRequest() { //Arrange var editedMessage = new MessageEditDTO() { Text = "", }; var message = new Message() { Id = 1, Text = "Message", UserId = 1, }; var _mockRepo = new Mock <IRepositoryWrapper>(); var _mockPrincipal = new Mock <IUserClaimsPrincipal>(); var _mockLogger = new Mock <ILoggerManager>(); _mockRepo.Setup(x => x.Message.UpdateMessageAsync(message)); _mockPrincipal.Setup(x => x.GetUserName(It.IsAny <ClaimsPrincipal>())).Returns("admin"); _mockRepo.Setup(x => x.User.GetUserByUserNameAsync("admin")).ReturnsAsync(1); var controller = new MessageController(_mockRepo.Object, _mockLogger.Object, _mockPrincipal.Object); //Act var actual = controller.Put(1, editedMessage); var actualResult = ((BadRequestObjectResult)actual.Result); //Assert Assert.Same(typeof(BadRequestObjectResult), actualResult.GetType()); Assert.Equal("Message object is not filled correct", (((ResponseVM)actualResult.Value).Title)); }
void TalkToPlayer() { MessageController.SetLookTarget(transform); if (!GameOrchestrator.Instance.SavedSailor) { MessageController.AddMessage("Well hello there, darling."); MessageController.AddMessage("You look mighty fine out there."); MessageController.AddMessage("My husband has been out on the sea all day..."); MessageController.AddMessage("*wink"); } else if (!GameOrchestrator.Instance.DeliveredSailor) { MessageController.AddMessage("HUGH! Where is our ship?!?!"); MessageController.AddMessage("SHARKS!?!?!"); MessageController.AddMessage("hmph.. well at least you're all right."); MessageController.AddMessage("Young sailor, thank you for bringing my husband home."); MessageController.AddMessage("That ship had been in our family for generations..."); MessageController.AddMessage("Let me sing you a song that my grandmother taught me. It is an old ballad that we would sing when ships didn't come home."); MessageController.AddMessage("You learned the SAD SHANTY! It's a song about loss on the high seas."); GameOrchestrator.Instance.HasSadShanty = true; GameOrchestrator.Instance.DeliveredSailor = true; } else { MessageController.AddMessage("There once was a ship, that could not be sunken -- at least so long the crew wern't drunken..."); } }
public void Should_UpdateNotMyMessageMockFunction_With_Return_Forbid() { //Arrange var editedMessage = new MessageEditDTO() { Text = "Update new Message", }; var message = new Message() { Id = 1, Text = "Message", UserId = 1, }; var _mockRepo = new Mock <IRepositoryWrapper>(); var _mockPrincipal = new Mock <IUserClaimsPrincipal>(); var _mockLogger = new Mock <ILoggerManager>(); _mockRepo.Setup(x => x.Message.UpdateMessageAsync(message)); _mockRepo.Setup(x => x.Message.GetMessageByIdAsync(1)).ReturnsAsync(message); _mockPrincipal.Setup(x => x.GetUserName(It.IsAny <ClaimsPrincipal>())).Returns("omidm"); _mockRepo.Setup(x => x.User.GetUserByUserNameAsync("omidm")).ReturnsAsync(2); var controller = new MessageController(_mockRepo.Object, _mockLogger.Object, _mockPrincipal.Object); //Act var actual = controller.Put(1, editedMessage); var actualResult = ((ForbidResult)actual.Result); //Assert Assert.Same(typeof(ForbidResult), actualResult.GetType()); }
public async Task GetMessageById_ShouldReturnMessage_WhenIdMatchesAndUserIsPermittedToAccess() { // Arrange const int messageId = 1; MessageResource expectedMessage = new MessageResource { MessageId = 1 }; _mediatorMock .Setup(m => m.Send(It.IsAny <MessageExistsQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); _mediatorMock .Setup(m => m.Send(It.IsAny <CanAccessMessageQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(true); _mediatorMock .Setup(m => m.Send(It.IsAny <GetMessageByIdQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(expectedMessage); MessageController controller = new MessageController(null, _mediatorMock.Object); // Act ActionResult <MessageResource> response = await controller.GetMessageById(messageId); // Assert OkObjectResult result = Assert.IsType <OkObjectResult>(response.Result); MessageResource message = Assert.IsType <MessageResource>(result.Value); Assert.NotNull(message); Assert.Equal(messageId, message.MessageId); }
public void Start() { scriptManager = GameObject.Find("ScriptManager").GetComponent<ScriptManager>(); spriteModels = scriptManager.spriteModels; turnController = scriptManager.turnController; messageController = scriptManager.messageController; cameraController = scriptManager.cameraController; grid = scriptManager.grid; }
/// <summary> /// Initializes a new instance of the <see cref="MessageControllerTests"/> class. /// </summary> public MessageControllerTests() { Business.Dependencies.Register(); this.alertManager = new Mock<IAlertManager>(); this.personManager = new Mock<IPersonManager>(); DIContainer.Instance.Resolve<IComponentSettingsEntities>().MaxPageSize = 2; DIContainer.Instance.Resolve<IComponentSettingsEntities>().GangwayApplicationId = "1"; this.messageController = new MessageController(this.alertManager.Object, this.personManager.Object); CommonHelper.MockHttpRequestContext(); SessionData.Instance.MasterData = CommonHelper.SetupMasterDataForUIControllers(); }
void Start() { scriptManager = GameObject.Find("ScriptManager").GetComponent<ScriptManager>(); turnController = scriptManager.turnController; dumbComputer = scriptManager.dumbComputer; messageController = scriptManager.messageController; gridscr = scriptManager.grid; placeunits = scriptManager.placeUnits; cameraController = scriptManager.cameraController; playerPieces = GameObject.Find("PlayerPieces"); }
void Awake() { if (messageController == null) { DontDestroyOnLoad(gameObject); messageController = this; } else if (messageController != this) { Destroy(gameObject); } LoadNewMessagingPanel(); }
private void SetupMessageControllerDelete(MessageController controller) { var config = new HttpConfiguration(); var request = new HttpRequestMessage(HttpMethod.Delete, "http://localhost:2943/api/message"); var route = config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); var routeData = new HttpRouteData(route); routeData.Values.Add("id", RouteParameter.Optional); routeData.Values.Add("controller", "message"); controller.ControllerContext = new HttpControllerContext(config, routeData, request); controller.Request = request; controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config; controller.Request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData; }
public void PostMessageTest() { bool isItemAdded = false; var repository = Mock.Create<IRepository>(); var value = new Message() { Title = "testTitle", Content = "testContent", ChannelId = "43242342", CreatedDateTime = DateTime.Now.ToString(), Status = "add", Type = MessageTypes.Text, }; Mock.Arrange(() => repository.Create(Arg.IsAny<Message>())) .DoInstead(() => isItemAdded = true) .Returns(value); var controller = new MessageController(repository); SetupMessageControllerPost(controller); controller.Post(value); Assert.IsTrue(isItemAdded); }
public void GetMessageTest() { var repository = Mock.Create<IRepository>(); var value = new Message() { Title = "testTitle", Content = "testContent", ChannelId = "43242342", CreatedDateTime = DateTime.Now.ToString(), Status = "add", Type = MessageTypes.Text, Id = "1235213432123" }; Mock.Arrange<Message>( () => repository.Find<Message>(m => m.Id == value.Id, null)) .IgnoreArguments() .Returns(value) .MustBeCalled(); var target = new MessageController(repository); var result = target.Get(value.Id); Assert.AreEqual(result.Id, value.Id); }
void Awake() { // Init Player Variables _livesLeft = MAX_LIVES; // Initialize Messenger Messenger = GetComponent<MessageController>(); Screen.fullScreen = true; //force fullscreen }
public Message(MessageController m, string mess, int type, float duration) { msg = mess; msgType = type; float posX = 0; float posY = 0; float width = BOX_WIDTH; float height = BOX_HEIGHT; skin = m.messageSkin; // Set Message Specific Variables switch (msgType) { case MSG_PICKUP: anchor = TextAnchor.MiddleLeft; textColor = new Color(0f, 0.8f, 0f, 1f); // Light Green height = BOX_HEIGHT / 2; posX = Screen.width * PICKUP_STARTPOSX; posY = Screen.height * PICKUP_STARTPOSY; break; case MSG_WARNING: anchor = TextAnchor.MiddleCenter; textColor = new Color(1f, 0f, 0f, 1f); // Red posX = (Screen.width - width) / 2; posY = 0; break; case MSG_HUD: anchor = TextAnchor.MiddleCenter; textColor = new Color(1f, 0f, 0f, 1f); // Red height = BOX_HEIGHT / 2; posX = (Screen.width - width) / 2; posY = Screen.height * HUD_STARTPOSY; break; case MSG_DIALOG: anchor = TextAnchor.MiddleLeft; skin = m.dialogSkin; skin.box.fontSize = 21; drawOutline = false; textColor = new Color(1f, 1f, 1f, 1f); // White width = DIALOG_BOX_WIDTH; height = DIALOG_BOX_HEIGHT; posX = (Screen.width - width) / 2; posY = (Screen.height - height) / 2 - 50; break; } move = 0; r = new Rect(posX, posY, width, height); startTime = Time.time; interval = duration; }
void Start() { Messenger = GetComponent<MessageController>(); Messenger.enabled = true; _player = GameObject.Find("Player").GetComponent<PlayerController>(); }