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

            Assert.AreEqual(value, property.Value());
        }
예제 #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);
        }
예제 #4
0
        public void Properties_NotEmpty_AfterCreateOne(UniverseSources source)
        {
            var asyncProperties = new AsyncProperties(Universe(source).Properties());

            asyncProperties.Create("Test Property");
            Assert.IsTrue(asyncProperties.Any());
        }
예제 #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);
        }
예제 #6
0
        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());
        }
예제 #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());
        }
예제 #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());
        }
예제 #9
0
        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);
        }
예제 #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());
        }
예제 #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);
        }
예제 #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));
        }
예제 #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());
        }
예제 #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());
        }
예제 #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);
        }
예제 #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());
        }
예제 #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());
        }
예제 #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());
        }
예제 #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());
        }
예제 #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);
        }
예제 #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);
        }
예제 #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());
        }
예제 #23
0
        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());
        }
예제 #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());
        }
예제 #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());
        }
예제 #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);
        }
예제 #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));
        }
예제 #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}");
            }
        }
예제 #29
0
 public void Constructor_NotEmptyCollection(UniverseSources source)
 {
     Assert.IsTrue(new ListPropertiesViewModel(
                       new TestDataUniverse(Universe(source))
                       ).PropertyPresenters.Any());
 }
예제 #30
0
        public void CreateCommand_CanExecute_NotEmptyParameter(UniverseSources source)
        {
            var createPlanet = new CreatePlanet(new AsyncPlanets(Universe(source).Planets()));

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