Exemple #1
0
        private async Task RemoveItemInNewList()
        {
            var vm = new ListEditionPageViewModel
            {
                IsNewParam = "true"
            };

            vm.IsNew.Should().BeTrue();
            await vm.LoadCommandAsync.ExecuteAsync(null);

            vm.ListVM.ItemsVM.Should().BeEmpty();
            vm.IsNewParam = "true";
            vm.IsNew.Should().BeTrue();
            vm.ListVM.Name = "Essential Items";
            string itemName = "Plumbus";
            await vm.ListVM.AddItemCommand.ExecuteAsync(itemName);

            vm.ListVM.ItemsVM.Should().NotBeEmpty();
            await vm.SaveList();

            var man = Container.Resolve <ListsManagerVM>();

            man.ListsVM.Should().Contain(vm.ListVM);

            man.CurrentList.ItemsVM.Count.Should().Be(1);
            var id = man.CurrentList.ItemsVM.FirstOrDefault()?.Id;

            await vm.ListVM.RemoveItemCommand.ExecuteAsync(id);

            await vm.SaveList();

            var list = man.ListsVM.Where(l => l.Equals(vm.ListVM)).FirstOrDefault();

            list.ItemsVM.Should().BeEmpty();
        }
Exemple #2
0
        private async Task SaveNewListWithItemsCommand()
        {
            var vm = new ListEditionPageViewModel
            {
                IsNewParam = "true"
            };

            vm.IsNew.Should().BeTrue();
            await vm.LoadCommandAsync.ExecuteAsync(null);

            vm.ListVM.Name = "Stuff";
            vm.ListVM.ItemsVM.Should().BeEmpty();
            vm.IsNew.Should().BeTrue();
            string itemName = "Plumbus";
            await vm.ListVM.AddItemCommand.ExecuteAsync(itemName);

            vm.ListVM.ItemsVM.Should().NotBeEmpty();
            string itemName2 = "Plumbus2";
            await vm.ListVM.AddItemCommand.ExecuteAsync(itemName2);

            await vm.SaveList();

            var man = Container.Resolve <ListsManagerVM>();

            man.ListsVM.Should().Contain(vm.ListVM);
            man.ListsVM.Count.Should().BeGreaterThan(0);
        }