public void Value_ReturnValuePassedToConstructor(UniverseSources source) { var value = "Test"; var property = new AsyncProperty(Universe(source).Properties().Create(value)); Assert.AreEqual(value, property.Value()); }
public void Planets_NotEmpty_AfterCreateOne(UniverseSources source) { var asyncPlanets = new AsyncPlanets(Universe(source).Planets()); asyncPlanets.Create("Test Planet"); Assert.IsTrue(asyncPlanets.Any()); }
public void Constructor_Initialize(UniverseSources source) { var vm = new ListPropertiesViewModel(new TestDataUniverse(Universe(source))); Assert.IsTrue(vm.PropertyPresenters.Any()); Assert.IsNotNull(vm.CreateProperty); }
public void Properties_NotEmpty_AfterCreateOne(UniverseSources source) { var asyncProperties = new AsyncProperties(Universe(source).Properties()); asyncProperties.Create("Test Property"); Assert.IsTrue(asyncProperties.Any()); }
public void Constructor_Initialize(UniverseSources source) { var vm = new MainViewModel(Universe(source)); Assert.IsNotNull(vm.ListPlanetsViewModel); Assert.IsNotNull(vm.ListPropertiesViewModel); Assert.IsNotNull(vm.PlanetDescriptionViewModel); }
public void Properties_Empty_AfterDelete(UniverseSources source) { var asyncProperties = new AsyncProperties(Universe(source).Properties()); asyncProperties.Create("Test Property"); asyncProperties.First().Delete(); Assert.IsFalse(asyncProperties.Any()); }
public void Planets_Empty_AfterDelete(UniverseSources source) { var asyncPlanets = new AsyncPlanets(Universe(source).Planets()); asyncPlanets.Create("Test Planet"); asyncPlanets.First().Delete(); Assert.IsFalse(asyncPlanets.Any()); }
public void Rename_ChangeName(UniverseSources source) { var planet = new TestDataUniverse(Universe(source)).Planets().First(); var name = "Test"; planet.Rename(name); Assert.AreEqual(name, planet.Name()); }
public void Constructor_Initialize(UniverseSources source) { var name = "Test"; var presenter = new PlanetPresenter(new AsyncPlanet(Universe(source).Planets().Create(name)), presenter1 => { }); Assert.IsNotNull(presenter.DeleteItem); Assert.IsNotNull(presenter.EditName); Assert.AreEqual(name, presenter.Text); }
public void Change_UpdateValue(UniverseSources source) { var value = "Test"; var property = new AsyncProperty(Universe(source).Properties().Create(value)); value = "Test2"; property.Change(value); Assert.AreEqual(value, property.Value()); }
public void Constructor_Initialize(UniverseSources source) { var value = "Test"; var presenter = new PropertyPresenter(new AsyncProperty(Universe(source).Properties().Create(value)), propertyPresenter => { }); Assert.AreEqual(value, presenter.Text); Assert.IsNotNull(presenter.DeleteItem); Assert.IsNotNull(presenter.EditName); }
public void AddProperty_CanExecute_AfterSelectAvailableProperty(UniverseSources source) { var dataUniverse = new TestDataUniverse(Universe(source)); var vm = new PlanetDescriptionViewModel(dataUniverse); vm.ShowPlanetDescription(null, dataUniverse.Planets().First()); vm.SelectedAvailableProperty = vm.AvailableToAddProperties.First(); Assert.IsTrue(vm.AddProperty.CanExecute(null)); }
public async Task DeletePlanet_Execute_RemovePlanet(UniverseSources source) { var universe = Universe(source); var command = new DeletePlanet(new AsyncPlanet(universe.Planets().Create(""))); Assert.IsTrue(command.CanExecute(null)); await command.ExecuteAsync(null); Assert.IsFalse(universe.Planets().Any()); }
public void Delete_RemoveItem(UniverseSources source) { var universe = Universe(source); var property = new AsyncProperty(universe.Properties().Create("")); Assert.IsTrue(universe.Properties().Any()); property.Delete(); Assert.IsFalse(universe.Properties().Any()); }
public void Constructor_Initialize(UniverseSources source) { var dataUniverse = new TestDataUniverse(Universe(source)); var vm = new PlanetDescriptionViewModel(dataUniverse); vm.ShowPlanetDescription(null, dataUniverse.Planets().First()); Assert.IsTrue(vm.AvailableToAddProperties.Any()); Assert.IsTrue(vm.PlanetProperties.Any()); Assert.IsNotNull(vm.AddProperty); }
public async Task DeleteItem_Execute(UniverseSources source) { var universe = Universe(source); var command = new DeleteProperty(new AsyncProperty(universe.Properties().Create(""))); Assert.IsTrue(command.CanExecute(null)); await command.ExecuteAsync(null); Assert.IsFalse(universe.Properties().Any()); }
public async Task EditName_Execute(UniverseSources source) { var property = new AsyncProperty(Universe(source).Properties().Create("")); var command = new EditPropertyValue(property); var value = "Test2"; Assert.IsTrue(command.CanExecute(value)); await command.ExecuteAsync(value); Assert.AreEqual(value, property.Value()); }
public async Task ChangeAsync_InvokePropertyChanged(UniverseSources source) { var property = new AsyncProperty(Universe(source).Properties().Create("")); var eventInvoked = false; property.PropertyChanged += (sender, args) => { eventInvoked = true; }; var value = "Test"; await property.ChangeAsync(value); Assert.IsTrue(eventInvoked); Assert.AreEqual(value, property.Value()); }
public void Delete_InvokeEvent(UniverseSources source) { var planets = Universe(source).Planets(); var planet = new AsyncPlanet(planets.Create("")); var invoked = false; planet.PlanetDeleted += (sender, args) => invoked = true; planet.Delete(); Assert.IsTrue(invoked); Assert.IsFalse(planets.Any()); }
public async Task CreateCommand_AddPlanet_NotEmptyParameter(UniverseSources source) { var planets = new AsyncPlanets(Universe(source).Planets()); var eventInvoked = false; planets.NewPlanetEvent += (sender, args) => eventInvoked = true; var createPlanet = new CreatePlanet(planets); await createPlanet.ExecuteAsync("Test"); Assert.IsTrue(planets.Any()); Assert.IsTrue(eventInvoked); }
public async Task RenameAsync_InvokeEvent(UniverseSources source) { var planet = new AsyncPlanet(Universe(source).Planets().Create("")); var invoked = false; planet.PlanetRenamed += (sender, args) => invoked = true; var name = "Test"; await planet.RenameAsync(name); Assert.AreEqual(name, await planet.NameAsync()); Assert.IsTrue(invoked); }
public async Task DeleteAsync_InvokePropertyDeleted(UniverseSources source) { var universe = Universe(source); var property = new AsyncProperty(universe.Properties().Create("")); var eventInvoked = false; property.PropertyDeleted += (sender, args) => { eventInvoked = true; }; await property.DeleteAsync(); Assert.IsTrue(eventInvoked); Assert.IsFalse(universe.Properties().Any()); }
public async Task CreateAsync_InvokeEvent(UniverseSources source) { var value = "TestPropertyValue"; var asyncProperties = new AsyncProperties(Universe(source).Properties()); var eventInvoked = false; asyncProperties.NewPropertyEvent += (sender, args) => eventInvoked = true; var property = await asyncProperties.CreateAsync(value); Assert.AreEqual(property.Value(), property.Value()); Assert.IsTrue(eventInvoked); Assert.IsTrue(asyncProperties.Any()); }
public async Task EditPlanetName_Execute_ChangeName(UniverseSources source) { var name = "Test"; var asyncPlanet = new AsyncPlanet(Universe(source).Planets().Create(name)); var command = new EditPlanetName(asyncPlanet); name = "Test2"; Assert.IsTrue(command.CanExecute(name)); await command.ExecuteAsync(name); Assert.AreEqual(name, asyncPlanet.Name()); }
public void Create_InvokeEvent(UniverseSources source) { var name = "TestPlanetName"; var asyncPlanets = new AsyncPlanets(Universe(source).Planets()); var eventInvoked = false; asyncPlanets.NewPlanetEvent += (sender, args) => { eventInvoked = true; }; var planet = asyncPlanets.Create(name); Assert.AreEqual(name, planet.Name()); Assert.IsTrue(eventInvoked); Assert.IsTrue(asyncPlanets.Any()); }
public async Task Execute_CallDelete(UniverseSources source) { var dataUniverse = new TestDataUniverse(Universe(source)); var asyncPlanetProperty = new AsyncPlanetProperty(dataUniverse.Planets().First().Properties().First()); var deleteItem = new DeleteItem(asyncPlanetProperty); var invoked = false; asyncPlanetProperty.Deleted += (sender, args) => invoked = true; await deleteItem.ExecuteAsync(null); Assert.IsTrue(invoked); }
public void AddProperty_AddProperty_AfterExecute(UniverseSources source) { var dataUniverse = new TestDataUniverse(Universe(source)); var vm = new PlanetDescriptionViewModel(dataUniverse); var planet = dataUniverse.Planets().First(); vm.ShowPlanetDescription(null, planet); vm.SelectedAvailableProperty = vm.AvailableToAddProperties.First(); var prop = vm.SelectedAvailableProperty.Property; vm.AddProperty.Execute(null); Assert.IsTrue(planet.Properties().Contains(prop)); }
protected IUniverse Universe(UniverseSources source) { switch (source) { case UniverseSources.InMemo: return(new Universe.Model.InMemory.Universe()); case UniverseSources.SQLite: return(new Universe.Model.Sqlite.SqliteUniverse(new SQLiteConnection("Data Source=:memory:") .OpenAndReturn())); default: throw new ArgumentException($"Unexpected {nameof(source)} value: {source}"); } }
public void Constructor_NotEmptyCollection(UniverseSources source) { Assert.IsTrue(new ListPropertiesViewModel( new TestDataUniverse(Universe(source)) ).PropertyPresenters.Any()); }
public void CreateCommand_CanExecute_NotEmptyParameter(UniverseSources source) { var createPlanet = new CreatePlanet(new AsyncPlanets(Universe(source).Planets())); Assert.IsTrue(createPlanet.CanExecute("Test")); }