public void Search_TemplateThatDoesntExist_VisibleViewModelsEmpty() { //Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam { Name = "Dummy" }; team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); //Act var evt = new SearchEvent { TextFilter = "This doesn't exist" }; // Action App.Current.EventsBroker.Publish(evt); //Assert Assert.AreEqual(0, templatesController.ViewModel.VisibleViewModels.Count); }
public void TestHandleSave_NonForcedNameChanged() { // Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam(); team.Name = "Test Team #1"; team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); DummyTeam team2 = team.Clone(); string expectedName = "Test Team #2"; team2.Name = expectedName; // Action App.Current.EventsBroker.Publish(new UpdateEvent <Team> () { Object = team2, Force = false }); // Assert mockDialogs.Verify(m => m.QuestionMessage(It.IsAny <string> (), null, It.IsAny <DummyTemplatesController> ()), Times.Once()); Assert.AreEqual(templatesController.ViewModel.ViewModels.First(x => x.ID == team.ID).Name, expectedName); Assert.IsFalse(templatesController.ViewModel.SaveCommand.CanExecute()); }
public void Search_TemplateExist_TemplateFound() { //Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam { Name = "Dummy" }; team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); //Act var evt = new SearchEvent { TextFilter = "Dummy" }; // Action App.Current.EventsBroker.Publish(evt); //Assert Assert.AreEqual(1, templatesController.ViewModel.VisibleViewModels.Count); Assert.AreEqual("Dummy", templatesController.ViewModel.VisibleViewModels.FirstOrDefault().Name); }
public void TestHandleSave_SaveStatic() { // Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam(); team.Name = "Test Team #1"; team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); DummyTeam team2 = team.Clone(); string expectedName = "Test Team #2"; team2.Name = expectedName; team2.Static = true; var evt = new UpdateEvent <Team> () { Object = team2, Force = true }; // Action App.Current.EventsBroker.Publish(evt); // Assert mockDialogs.Verify(m => m.QuestionMessage(It.IsAny <string> (), null, It.IsAny <DummyTemplatesController> ()), Times.Once()); }
public void Reset_NewViewModel_CollectionReplaced() { // Arrange Utils.PlayerDummy m = new Utils.PlayerDummy(); Utils.PlayerDummy modelNotified = null; CollectionViewModel <Utils.PlayerDummy, DummyPlayerVM> collection = new CollectionViewModel <Utils.PlayerDummy, DummyPlayerVM> (); collection.ViewModels.Add(new DummyPlayerVM { Model = m }); Utils.PlayerDummy mToUpdate = new Utils.PlayerDummy(); var vmToUpdate = new DummyPlayerVM { Model = mToUpdate }; // Act collection.ViewModels.Reset(new List <DummyPlayerVM> { vmToUpdate }); // Assert Assert.AreEqual(1, collection.ViewModels.Count()); }
public void TestHandleSave_ForcedNameChanged() { // Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam(); team.Name = "Test Team #1"; team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); DummyTeam team2 = team.Clone(); string expectedName = "Test Team #2"; team2.Name = expectedName; // Action App.Current.EventsBroker.Publish(new UpdateEvent <Team> () { Object = team2, Force = true }); // Assert Assert.AreEqual(templatesController.ViewModel.ViewModels.First(x => x.ID == team.ID).Name, expectedName); Assert.IsFalse(templatesController.ViewModel.SaveCommand.CanExecute()); }
public void ReplaceModelFromCollection_VMAddedToLimitedVM_UpdatedOk() { // Arrange LimitedCollectionViewModel <Utils.PlayerDummy, DummyPlayerVM> collection = new LimitedCollectionViewModel <Utils.PlayerDummy, DummyPlayerVM> (); collection.Limitation = new CountLimitationVM { Model = new CountLicenseLimitation { Maximum = 1, Enabled = true } }; collection.ViewModels.Add(new DummyPlayerVM { Model = new Utils.PlayerDummy() }); collection.ViewModels.Add(new DummyPlayerVM { Model = new Utils.PlayerDummy() }); // Act var model = new Utils.PlayerDummy(); collection.Model.Reset(new List <Utils.PlayerDummy> { model }); // Assert Assert.AreEqual(1, collection.Model.Count); Assert.AreEqual(1, collection.ViewModels.Count); Assert.AreEqual(1, ((CollectionViewModel <Utils.PlayerDummy, DummyPlayerVM>)collection).ViewModels.Count); Assert.AreEqual(1, collection.LimitedViewModels.Count); Assert.IsTrue(collection.ViewModels.Any(x => x.Model == model)); }
public void TestToString() { Utils.PlayerDummy player = new Utils.PlayerDummy { Name = "andoni", LastName = "morales" }; Assert.AreEqual("andoni morales", player.ToString()); player.NickName = "ylatuya"; Assert.AreEqual("ylatuya", player.ToString()); }
public void TestPhoto() { Utils.PlayerDummy player = new Utils.PlayerDummy { Name = "andoni", Nationality = "spanish" }; player.Photo = Utils.LoadImageFromFile(); Utils.CheckSerialization(player); Assert.AreEqual(player.Photo.Width, 16); Assert.AreEqual(player.Photo.Height, 16); }
public void TestSelect() { var model = new DummyTeam { Name = "dash", }; var player = new Utils.PlayerDummy(); model.List.Add(player); var viewModel = new DummyTeamVM { Model = model }; viewModel.Select(viewModel.ViewModels.First()); Assert.AreEqual(1, viewModel.Selection.Count); Assert.AreEqual(player, viewModel.Selection.First().Model); }
public void TestSerialization() { Utils.PlayerDummy player = new Utils.PlayerDummy { Name = "andoni", Nationality = "spanish", Mail = "test@test", Color = Color.Red }; Utils.CheckSerialization(player); Player newPlayer = Utils.SerializeDeserialize(player); Assert.AreEqual(player.Name, newPlayer.Name); Assert.AreEqual(player.Nationality, newPlayer.Nationality); Assert.AreEqual(player.Mail, newPlayer.Mail); Assert.IsNull(newPlayer.Color); }
public void Add_ViewModel_AddModelBeforeNotify() { // Arrange Utils.PlayerDummy m = new Utils.PlayerDummy(); Utils.PlayerDummy modelNotified = null; CollectionViewModel <Utils.PlayerDummy, DummyPlayerVM> collection = new CollectionViewModel <Utils.PlayerDummy, DummyPlayerVM> (); collection.GetNotifyCollection().CollectionChanged += (sender, e) => modelNotified = ((DummyPlayerVM)e.NewItems [0]).Model; // Act collection.ViewModels.Add(new DummyPlayerVM { Model = m }); // Assert Assert.AreEqual(m, modelNotified); }
public TeamVM PrepareExport() { Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam(); team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); templatesController.ViewModel.Selection.Add(teamVM); tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); tempFile = Path.ChangeExtension(tempFile, null); mockDialogs.Setup(m => m.SaveFile(It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string []> ())). Returns(tempFile); return(teamVM); }
public void TestHandleSelectionChanged_LoadedTemplateWithTeamAndPlayer() { // Arrange Utils.PlayerDummy player = new Utils.PlayerDummy(); DummyTeam team = new DummyTeam(); team.List.Add(player); TeamVM teamVM = new TeamVM { Model = team }; templatesController.ViewModel.ViewModels.Add(teamVM); // Action templatesController.ViewModel.Selection.Replace(templatesController.ViewModel.ViewModels); // Assert Assert.IsNotNull(templatesController.ViewModel.LoadedTemplate, "Loaded template model"); Assert.IsNotEmpty(templatesController.ViewModel.LoadedTemplate.SubViewModel, "Loaded template subVM"); }