Exemple #1
0
        public async Task SettingOrderPropertyShouldRaisePropertyChanged()
        {
            bool invoked = false;

            Xamarin.Forms.DependencyService.RegisterSingleton <ISettingsService>(new MockSettingsService());
            var orderService = new OrderMockService();

            Xamarin.Forms.DependencyService.RegisterSingleton <IOrderService>(orderService);
            var orderViewModel = new OrderDetailViewModel();

            orderViewModel.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName.Equals("Order"))
                {
                    invoked = true;
                }
            };
            var order = await orderService.GetOrderAsync(1, GlobalSetting.Instance.AuthToken);

            await orderViewModel.InitializeAsync(new Dictionary <string, string> {
                { nameof(Order.OrderNumber), order.OrderNumber.ToString() }
            });

            Assert.True(invoked);
        }
Exemple #2
0
        public async Task GetFakeOrdersTest()
        {
            var ordersMockService = new OrderMockService();
            var result            = await ordersMockService.GetOrdersAsync(GlobalSetting.Instance.AuthToken);

            Assert.NotEmpty(result);
        }
Exemple #3
0
        public async Task GetFakeOrderTest()
        {
            var ordersMockService = new OrderMockService();
            var order             = await ordersMockService.GetOrderAsync(1, GlobalSetting.Instance.AuthToken);

            Assert.NotNull(order);
        }
        public void OrderPropertyIsNullWhenViewModelInstantiatedTest()
        {
            var orderService   = new OrderMockService();
            var orderViewModel = new OrderDetailViewModel(orderService);

            Assert.Null(orderViewModel.Order);
        }
        public async Task OrderPropertyIsNotNullAfterViewModelInitializationTest()
        {
            var orderService   = new OrderMockService();
            var orderViewModel = new OrderDetailViewModel(orderService);

            var order = await orderService.GetOrderAsync(1, GlobalSetting.Instance.AuthToken);

            await orderViewModel.InitializeAsync(order);

            Assert.NotNull(orderViewModel.Order);
        }
Exemple #6
0
        public async Task OrderPropertyIsNotNullAfterViewModelInitializationTest()
        {
            Xamarin.Forms.DependencyService.RegisterSingleton <ISettingsService>(new MockSettingsService());
            var orderService = new OrderMockService();

            Xamarin.Forms.DependencyService.RegisterSingleton <IOrderService>(orderService);
            var orderViewModel = new OrderDetailViewModel();

            var order = await orderService.GetOrderAsync(1, GlobalSetting.Instance.AuthToken);

            await orderViewModel.InitializeAsync(new Dictionary <string, string> {
                { nameof(Order.OrderNumber), order.OrderNumber.ToString() }
            });

            Assert.NotNull(orderViewModel.Order);
        }
        public async Task SettingOrderPropertyShouldRaisePropertyChanged()
        {
            bool invoked        = false;
            var  orderService   = new OrderMockService();
            var  orderViewModel = new OrderDetailViewModel(orderService);

            orderViewModel.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName.Equals("Order"))
                {
                    invoked = true;
                }
            };
            var order = await orderService.GetOrderAsync(1, GlobalSetting.Instance.AuthToken);

            await orderViewModel.InitializeAsync(order);

            Assert.True(invoked);
        }
Exemple #8
0
 public OrdersController()
 {
     _orderService = new OrderMockService();
 }