public async Task BrandsPropertyIsNotNullAfterViewModelInitializationTest()
        {
            var catalogService   = new CatalogMockService();
            var catalogViewModel = new CatalogViewModel(catalogService);

            await catalogViewModel.InitializeAsync(null);

            Assert.NotNull(catalogViewModel.Brands);
        }
示例#2
0
        public async Task ProductsPropertyIsNotNullAfterViewModelInitializationTest()
        {
            var catalogService   = new CatalogMockService(_dependencyService);
            var catalogViewModel = new CatalogViewModel(catalogService);

            await catalogViewModel.InitializeAsync(null);

            Assert.NotNull(catalogViewModel.Products);
        }
示例#3
0
        public async Task TypesPropertyIsNotNullAfterViewModelInitializationTest()
        {
            Xamarin.Forms.DependencyService.RegisterSingleton <ISettingsService>(new MockSettingsService());
            Xamarin.Forms.DependencyService.RegisterSingleton <ICatalogService>(new CatalogMockService());
            var catalogViewModel = new CatalogViewModel();

            await catalogViewModel.InitializeAsync(null);

            Assert.NotNull(catalogViewModel.Types);
        }
        public async Task ClearFilterCommandResetsPropertiesTest()
        {
            var catalogService   = new CatalogMockService();
            var catalogViewModel = new CatalogViewModel(catalogService);

            await catalogViewModel.InitializeAsync(null);

            catalogViewModel.ClearFilterCommand.Execute(null);

            Assert.Null(catalogViewModel.Brand);
            Assert.Null(catalogViewModel.Type);
            Assert.NotNull(catalogViewModel.Products);
        }
示例#5
0
        public async Task ClearFilterCommandResetsPropertiesTest()
        {
            Xamarin.Forms.DependencyService.RegisterSingleton <ISettingsService>(new MockSettingsService());
            Xamarin.Forms.DependencyService.RegisterSingleton <ICatalogService>(new CatalogMockService());
            var catalogViewModel = new CatalogViewModel();

            await catalogViewModel.InitializeAsync(null);

            catalogViewModel.ClearFilterCommand.Execute(null);

            Assert.Null(catalogViewModel.Brand);
            Assert.Null(catalogViewModel.Type);
            Assert.NotNull(catalogViewModel.Products);
        }
        public async Task SettingTypesPropertyShouldRaisePropertyChanged()
        {
            bool invoked          = false;
            var  catalogService   = new CatalogMockService();
            var  catalogViewModel = new CatalogViewModel(catalogService);

            catalogViewModel.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName.Equals("Types"))
                {
                    invoked = true;
                }
            };
            await catalogViewModel.InitializeAsync(null);

            Assert.True(invoked);
        }
        public async Task FilterCommandSendsFilterMessageTest()
        {
            bool messageReceived  = false;
            var  catalogService   = new CatalogMockService();
            var  catalogViewModel = new CatalogViewModel(catalogService);
            await catalogViewModel.InitializeAsync(null);

            catalogViewModel.Brand = catalogViewModel.Brands.FirstOrDefault();
            catalogViewModel.Type  = catalogViewModel.Types.FirstOrDefault();

            Xamarin.Forms.MessagingCenter.Subscribe <CatalogViewModel>(this, MessageKeys.Filter, (sender) =>
            {
                messageReceived = true;
            });
            catalogViewModel.FilterCommand.Execute(null);

            Assert.True(messageReceived);
        }
示例#8
0
        public async Task SettingTypesPropertyShouldRaisePropertyChanged()
        {
            bool invoked = false;

            Xamarin.Forms.DependencyService.RegisterSingleton <ISettingsService>(new MockSettingsService());
            Xamarin.Forms.DependencyService.RegisterSingleton <ICatalogService>(new CatalogMockService());
            var catalogViewModel = new CatalogViewModel();

            catalogViewModel.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName.Equals("Types"))
                {
                    invoked = true;
                }
            };
            await catalogViewModel.InitializeAsync(null);

            Assert.True(invoked);
        }