public void SetCondensedTreeState_SavedTreeStateIsCompatible_ShouldSetTreeState() { // Arrange var buildingPresetsVersion = "1.0"; var buildingPresets = new BuildingPresets(); buildingPresets.Buildings = new List <BuildingInfo>(); buildingPresets.Version = buildingPresetsVersion; var viewModel = new PresetsTreeViewModel(_mockedTreeLocalization); viewModel.LoadItems(buildingPresets); var(items, expectedState) = GetTreeAndState(expandLastMainNode: false); viewModel.Items.Clear(); foreach (var curItem in items) { viewModel.Items.Add(curItem); } var savedTreeState = new Dictionary <int, bool> { { 4, true }, { 5, false } }; // Act viewModel.SetCondensedTreeState(savedTreeState, buildingPresetsVersion); // Assert var currentState = viewModel.GetCondensedTreeState(); Assert.Equal(savedTreeState, currentState); }
public void SetCondensedTreeState_LastPresetsVersionIsNullOrWhiteSpace_ShouldNotSetAnyStateAndNotThrow(string lastBuildingPresetsVersionToSet) { // Arrange var viewModel = new PresetsTreeViewModel(_mockedTreeLocalization); var(items, expectedState) = GetTreeAndState(); viewModel.Items = new ObservableCollection <GenericTreeItem>(items); // Act viewModel.SetCondensedTreeState(new Dictionary <int, bool>(), lastBuildingPresetsVersionToSet); // Assert Assert.Equal(expectedState, viewModel.GetCondensedTreeState()); }
public void SetCondensedTreeState_SavedTreeStateIsNull_ShouldNotSetAnyStateAndNotThrow() { // Arrange var buildingPresetsVersion = "1.0"; var buildingPresets = new BuildingPresets(); buildingPresets.Buildings = new List <BuildingInfo>(); buildingPresets.Version = buildingPresetsVersion; var viewModel = new PresetsTreeViewModel(_mockedTreeLocalization); viewModel.LoadItems(buildingPresets); var(items, expectedState) = GetTreeAndState(); viewModel.Items = new ObservableCollection <GenericTreeItem>(items); // Act viewModel.SetCondensedTreeState(null, buildingPresetsVersion); // Assert Assert.Equal(expectedState, viewModel.GetCondensedTreeState()); }
public void SetCondensedTreeState_LastPresetsVersionIsDifferent_ShouldNotSetAnyStateAndNotThrow() { // Arrange var buildingPresetsVersion = "1.0"; var buildingPresets = new BuildingPresets(); buildingPresets.Buildings = new List <BuildingInfo>(); buildingPresets.Version = buildingPresetsVersion; var viewModel = new PresetsTreeViewModel(_mockedTreeLocalization, _mockedCommons); viewModel.LoadItems(buildingPresets); var(items, expectedState) = GetTreeAndState(); viewModel.Items = new ObservableCollection <GenericTreeItem>(items); // Act viewModel.SetCondensedTreeState(new Dictionary <int, bool>(), "2.0"); // Assert Assert.Equal(expectedState, viewModel.GetCondensedTreeState()); }