public void DoesNotCallSteamProxyWhenApplicationIsNull() { var steamProxyMock = MockRepository.GenerateMock<ISteamProxy>(); var factoryMock = MockRepository.GenerateMock<IFilteredApplicationCategoryFactory>(); var viewModel = new MainWindowViewModel(steamProxyMock, factoryMock, null); viewModel.Launch(null); steamProxyMock.AssertWasNotCalled(x => x.LaunchApp(Arg<int>.Is.Anything)); }
public void CallsSteamProxyWithIdOfProvidedApplication() { var steamProxyMock = MockRepository.GenerateMock<ISteamProxy>(); var applicationMock = MockRepository.GenerateMock<IApplication>(); applicationMock.Stub(x => x.Id).Return(8); var factoryMock = MockRepository.GenerateMock<IFilteredApplicationCategoryFactory>(); var viewModel = new MainWindowViewModel(steamProxyMock, factoryMock, null); viewModel.Launch(applicationMock); steamProxyMock.AssertWasCalled(x => x.LaunchApp(applicationMock.Id), c => c.Repeat.Once()); }
public void UpdatesFilteredApplicationCategoriesWhenFilterChanges() { var categoryMock = MockRepository.GenerateMock<IFilteredApplicationCategory>(); var factoryMock = MockRepository.GenerateMock<IFilteredApplicationCategoryFactory>(); factoryMock.Stub(x => x.Build()).Return(new [] { categoryMock }); var viewModel = new MainWindowViewModel(null, factoryMock, null); categoryMock.AssertWasNotCalled(x => x.Filter); var filterValue = "test"; viewModel.Filter = filterValue; categoryMock.AssertWasCalled(x => x.Filter, c => c.Repeat.Once().SetPropertyWithArgument(filterValue)); }
public void NotifiesPropertyChangedWhenFilterChanges() { var factoryMock = MockRepository.GenerateMock<IFilteredApplicationCategoryFactory>(); factoryMock.Stub(x => x.Build()).Return(new IFilteredApplicationCategory[] { }); var viewModel = new MainWindowViewModel(null, factoryMock, null); var wasPropertyChangedCalled = false; viewModel.PropertyChanged += (s, e) => { wasPropertyChangedCalled = true; Assert.AreEqual("Filter", e.PropertyName); }; Assert.IsFalse(wasPropertyChangedCalled); viewModel.Filter = "test"; Assert.IsTrue(wasPropertyChangedCalled); }