public void MediatorTest() { MyMessageMediator mediator = new MyMessageMediator(); IoCContainer.Kernel = new StandardKernel(); IoCContainer.Kernel.Bind <IMediator>().ToConstant <IMediator>(mediator).InSingletonScope(); var testClass = new TestClass(); var storage = IoCContainer.Kernel.Get <IMediator>(); storage.SendMessage <long>(1, MsgTag.CloseLogin); Assert.AreEqual("1", testClass.testValue); storage.SendMessage <string>("2", MsgTag.CloseLogin); Assert.AreEqual("12", testClass.testValue); Assert.AreEqual(2, ((MessageStorage)testClass.Mediator).actions.Count); testClass.Close(); TestClass testClass2 = new TestClass(); storage.SendMessage <long>(10, MsgTag.CloseLogin); storage.SendMessage <string>("10", MsgTag.CloseLogin); Assert.AreEqual("1010", testClass2.testValue); Assert.AreEqual("12", testClass.testValue); Assert.AreEqual(2, ((MessageStorage)testClass2.Mediator).actions.Count); }
public void AskCAshpoolDisabledAnonymousBetting() { IoCContainer.Kernel.Unbind <IMediator>(); var MessageMediator = new MyMessageMediator(); IoCContainer.Kernel.Bind <IMediator>().ToConstant <IMediator>(MessageMediator).InSingletonScope(); TranslationProvider.Setup(x => x.Translate(MultistringTags.TERMINAL_CREDITNOTE_MOVECREDITTOBALANCE_LOGIN)).Returns("move {0}"); QuestionWindowService.Setup(x => x.ShowMessage(It.IsAny <string>())); var model = new MainViewModel(); MessageMediator.SendMessage <decimal>(20m, MsgTag.AskAboutCashPool); QuestionWindowService.Verify(x => x.ShowMessage(It.IsAny <string>()), Times.Never); }
public void SportFiltersCheckPreMatch() { IoCContainer.Kernel.Unbind <IMediator>(); var MessageMediator = new MyMessageMediator(); IoCContainer.Kernel.Bind <IMediator>().ToConstant <IMediator>(MessageMediator).InSingletonScope(); ChangeTracker.Setup(x => x.SelectedDescriptorsPreMatch).Returns(new List <string>()); Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(new SortableObservableCollection <IMatchVw>()); var prematch = new MatchesViewModel(); prematch.OnNavigationCompleted(); MessageMediator.SendMessage(true, MsgTag.ClearSelectedSports); //at start should be only "All sports" available and checked Assert.AreEqual(1, prematch.SportsBarItemsPreMatch.Count); Assert.AreEqual(1, prematch.SelectedDescriptors.Count); Assert.AreEqual(SportSr.ALL_SPORTS, prematch.SelectedDescriptors[0]); //if something else is checked, there should be no "All sports" in selected descriptors SportBarItem hokkey = new SportBarItem("Ice Hokkey", SportSr.SPORT_DESCRIPTOR_ICE_HOCKEY); SportBarItem soccer = new SportBarItem("Soccer", SportSr.SPORT_DESCRIPTOR_SOCCER); SportBarItem volley = new SportBarItem("Volleyball", SportSr.SPORT_DESCRIPTOR_VOLLEYBALL); prematch.OnCheckedExecute(hokkey); Assert.AreEqual(1, prematch.SportsBarItemsPreMatch.Count); Assert.AreEqual(1, prematch.SelectedDescriptors.Count); Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_ICE_HOCKEY, prematch.SelectedDescriptors[0]); //select all sport once again, other selection should be dropped SportBarItem allsports = new SportBarItem("All Sports", SportSr.ALL_SPORTS); prematch.OnCheckedExecute(allsports); Assert.AreEqual(1, prematch.SportsBarItemsPreMatch.Count); Assert.AreEqual(1, prematch.SelectedDescriptors.Count); Assert.AreEqual(SportSr.ALL_SPORTS, prematch.SelectedDescriptors[0]); //all sports cannot be unchecked if pressed twice prematch.OnCheckedExecute(allsports); Assert.AreEqual(1, prematch.SelectedDescriptors.Count); Assert.AreEqual(SportSr.ALL_SPORTS, prematch.SelectedDescriptors[0]); //same item pressed twice should be unchecked and if no other item selected all sports should be checked prematch.OnCheckedExecute(soccer); prematch.OnCheckedExecute(hokkey); Assert.AreEqual(2, prematch.SelectedDescriptors.Count); prematch.OnCheckedExecute(hokkey); Assert.AreEqual(1, prematch.SelectedDescriptors.Count); Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_SOCCER, prematch.SelectedDescriptors[0]); prematch.OnCheckedExecute(soccer); Assert.AreEqual(1, prematch.SelectedDescriptors.Count); Assert.AreEqual(SportSr.ALL_SPORTS, prematch.SelectedDescriptors[0]); //two items can be selected in same time prematch.OnCheckedExecute(hokkey); prematch.OnCheckedExecute(soccer); prematch.OnCheckedExecute(volley); Assert.AreEqual(3, prematch.SelectedDescriptors.Count); Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_ICE_HOCKEY, prematch.SelectedDescriptors[0]); Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_SOCCER, prematch.SelectedDescriptors[1]); Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_VOLLEYBALL, prematch.SelectedDescriptors[2]); }