public void Value_ReturnValuePassedToConstructor(UniverseSources source)
        {
            var value    = "Test";
            var property = new AsyncProperty(Universe(source).Properties().Create(value));

            Assert.AreEqual(value, property.Value());
        }
Esempio n. 2
0
        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());
        }
Esempio n. 5
0
        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());
        }
Esempio n. 7
0
        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());
        }
Esempio n. 8
0
        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);
        }
Esempio n. 10
0
        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());
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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));
        }
Esempio n. 13
0
        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());
        }
Esempio n. 14
0
        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());
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        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());
        }
Esempio n. 17
0
        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());
        }
Esempio n. 18
0
        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());
        }
Esempio n. 19
0
        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());
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
        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());
        }
Esempio n. 24
0
        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());
        }
Esempio n. 25
0
        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());
        }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
        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));
        }
Esempio n. 28
0
        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}");
            }
        }
Esempio n. 29
0
 public void Constructor_NotEmptyCollection(UniverseSources source)
 {
     Assert.IsTrue(new ListPropertiesViewModel(
                       new TestDataUniverse(Universe(source))
                       ).PropertyPresenters.Any());
 }
Esempio n. 30
0
        public void CreateCommand_CanExecute_NotEmptyParameter(UniverseSources source)
        {
            var createPlanet = new CreatePlanet(new AsyncPlanets(Universe(source).Planets()));

            Assert.IsTrue(createPlanet.CanExecute("Test"));
        }