Пример #1
0
        public async Task Push_And_Prepare_Model(string stringValue)
        {
            var container = new Container();
            var app       = new Application();

            ZeroApp
            .On(app)
            .WithContainer(DryIocZeroContainer.Build(container))
            .RegisterShell(() => new FirstShell())
            .Start();

            var firstViewModel  = container.Resolve <FirstViewModel>();
            var secondViewModel = container.Resolve <SecondViewModel>();

            var secondViewModelPageBeforePush          = secondViewModel.CurrentPage;
            var secondViewModelPreviousModelBeforePush = secondViewModel.PreviousModel;

            Assert.IsNull(secondViewModelPageBeforePush);
            Assert.IsNull(secondViewModelPreviousModelBeforePush);
            Assert.IsNull(secondViewModel.SecondStringProperty);

            await firstViewModel.Push <SecondPage>(stringValue);

            var secondViewModelPageAfterPush          = secondViewModel.CurrentPage;
            var secondViewModelPreviousModelAfterPush = secondViewModel.PreviousModel;

            Assert.IsNotNull(secondViewModelPageAfterPush);
            Assert.IsNotNull(secondViewModelPreviousModelAfterPush);
            Assert.AreEqual(secondViewModelPageAfterPush.GetType(), typeof(SecondPage));
            Assert.AreEqual(secondViewModelPreviousModelAfterPush.GetType(), typeof(FirstViewModel));
            Assert.AreEqual(firstViewModel, secondViewModel.PreviousModel);
            Assert.IsNotNull(secondViewModel.SecondStringProperty);
            Assert.AreEqual(stringValue, secondViewModel.SecondStringProperty);
        }
Пример #2
0
        public void ShellPagedViewModel_Markup_Returns_ActualViewModel()
        {
            var container = new Container();
            var app       = new Application();

            ZeroApp
            .On(app)
            .WithContainer(DryIocZeroContainer.Build(container))
            .RegisterShell(() => new FirstShell())
            .Start();

            var firstPage = container.Resolve <FirstPage>();

            var markup = new ShellPagedViewModelMarkup()
            {
                ViewModel = typeof(FirstViewModel),
                Page      = firstPage
            };

            var provider = new XamlServiceProvider();

            var vmValue = (FirstViewModel)markup.ProvideValue(provider);

            Assert.AreEqual(typeof(FirstViewModel), vmValue.GetType());
            Assert.AreEqual(vmValue, container.Resolve <FirstViewModel>());
        }
Пример #3
0
        /// <summary>
        ///     配置使用MessageMVC
        /// </summary>
        /// <param name="builder">主机生成器</param>
        /// <param name="registAction">配置注册方法</param>
        /// <param name="autoDiscovery">自动发现</param>
        /// <param name="discovery">自定义API发现方法</param>
        internal static void UseMessageMVC(this IWebHostBuilder builder, Action <IServiceCollection> registAction, bool autoDiscovery, Action discovery)
        {
            Console.Write(@"-------------------------------------------------------------
---------------> ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(@"Wecome ZeroTeam MessageMVC");
            Console.ResetColor();
            Console.WriteLine(@" <----------------
-------------------------------------------------------------");
            builder.ConfigureAppConfiguration((ctx, builder) =>
            {
                DependencyHelper.ServiceCollection.AddSingleton(p => builder);
                ConfigurationHelper.BindBuilder(builder);
                ZeroFlowControl.LoadConfig();

                ZeroAppOption.Instance.AutoDiscover       = autoDiscovery;
                ZeroAppOption.Instance.Discovery          = discovery;
                ConfigurationHelper.OnConfigurationUpdate = cfg => ctx.Configuration = cfg;
                ctx.Configuration = ConfigurationHelper.Root;
            })
            .ConfigureServices((ctx, services) =>
            {
                DependencyHelper.Binding(services);
                services.AddHostedService <ZeroHostedService>();
                registAction(services);
                ZeroApp.AddDependency(services);
            });
        }
Пример #4
0
        public App()
        {
            this.InitializeComponent();

            ZeroApp.On(this)
            .WithContainer(TinyIocZeroContainer.Build())
            .RegisterShell(() => new AppShell())
            .RegisterShell(() => new TabbedShell())
            .StartWith <AppShell>();
        }
Пример #5
0
        public void SetUp()
        {
            Xamarin.Forms.Mocks.MockForms.Init();
            this._tinyIoCContainer = new TinyIoCContainer();
            this._app = new Application();

            ZeroApp
            .On(this._app)
            .WithContainer(TinyIocZeroContainer.Build(this._tinyIoCContainer))
            .RegisterShell(() => new FirstShell())
            .Start();
        }
Пример #6
0
        public void SetUp()
        {
            Xamarin.Forms.Mocks.MockForms.Init();
            this._kernel = new StandardKernel();
            this._app    = new Application();

            ZeroApp
            .On(this._app)
            .WithContainer(NinjectZeroContainer.Build(this._kernel))
            .RegisterShell(() => new FirstShell())
            .Start();
        }
Пример #7
0
        public App()
        {
            this.InitializeComponent();

            ZeroApp
            .On(this)
            .WithContainer(NinjectZeroContainer.Build(Kernel))
            .RegisterShell(() => new SimpleShell())
            .RegisterShell(() => new TabbedShell())
            .StartWith <SimpleShell>();

            Kernel.Bind <IDummyService>().To <DummyService>().InSingletonScope();
        }
Пример #8
0
        public void Test_ViewModels_ShellService_And_MessagingCenter_Are_Registered_On_Startup()
        {
            var container = new Container();
            var app       = new Application();

            ZeroApp
            .On(app)
            .WithContainer(DryIocZeroContainer.Build(container))
            .RegisterShell(() => new FirstShell())
            .Start();

            var firstViewModel  = container.Resolve <FirstViewModel>();
            var secondViewModel = container.Resolve <SecondViewModel>();

            var shellService    = container.Resolve <IShellService>();
            var messagingCenter = container.Resolve <IMessagingCenter>();

            Assert.NotNull(firstViewModel);
            Assert.NotNull(secondViewModel);
            Assert.NotNull(shellService);
            Assert.NotNull(messagingCenter);
        }
Пример #9
0
        public async Task Pop_And_ReversePrepare_Model(string stringValue)
        {
            var container = new Container();
            var app       = new Application();

            ZeroApp
            .On(app)
            .WithContainer(DryIocZeroContainer.Build(container))
            .RegisterShell(() => new FirstShell())
            .Start();

            var firstViewModel  = container.Resolve <FirstViewModel>();
            var secondViewModel = container.Resolve <SecondViewModel>();

            Assert.AreEqual(firstViewModel.CurrentPage.GetType(), typeof(FirstPage));
            Assert.IsNull(secondViewModel.CurrentPage);

            Assert.AreEqual(firstViewModel.CurrentPage.Navigation.NavigationStack.Count, 1);

            await firstViewModel.Push <SecondPage>();

            Assert.AreEqual(firstViewModel.CurrentPage.Navigation.NavigationStack.Count, 2);

            Assert.AreEqual(firstViewModel.CurrentPage.GetType(), typeof(FirstPage));
            Assert.AreEqual(secondViewModel.CurrentPage.GetType(), typeof(SecondPage));

            await secondViewModel.Pop(stringValue);

            Assert.AreEqual(firstViewModel.CurrentPage.Navigation.NavigationStack.Count, 1);

            Assert.AreEqual(firstViewModel.CurrentPage.GetType(), typeof(FirstPage));
            Assert.AreEqual(secondViewModel.CurrentPage.GetType(), typeof(SecondPage));

            Assert.NotNull(firstViewModel.FirstStringProperty);
            Assert.AreEqual(firstViewModel.FirstStringProperty, stringValue);
        }
Пример #10
0
 /// <summary>
 /// Register all viewmodel that extend ZeroBaseModel
 /// </summary>
 public static void RegisterViewModels()
 {
     ZeroApp.RegisterMany(type => type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(ZeroBaseModel)));
 }
Пример #11
0
 public UnitCodeBuilder()
 {
     ZeroApp.UseTest(IocHelper.ServiceCollection);
 }
Пример #12
0
 public TestControlerUnitTest()
 {
     ZeroApp.UseTest(IocHelper.ServiceCollection, typeof(TestControler).Assembly);
 }
Пример #13
0
 public void SetUp()
 {
     ZeroApp.UseTest(DependencyHelper.ServiceCollection).Wait();
 }
Пример #14
0
 public void Setup()
 {
     ZeroApp.UseTest(DependencyHelper.ServiceCollection, typeof(NetEventControler).Assembly).Wait();
 }
Пример #15
0
 /// <summary>
 /// Register all content page
 /// </summary>
 /// <param name="pagesAreTransient"></param>
 public static void RegisterPages(bool pagesAreTransient)
 {
     ZeroApp.RegisterMany(type => type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(ContentPage)), pagesAreTransient);
 }
Пример #16
0
 /// <summary>
 /// Register all viewmodel that extend ZeroBaseModel
 /// </summary>
 /// <param name="viewmodelsAreTransient"></param>
 public static void RegisterViewModels(bool viewmodelsAreTransient)
 {
     ZeroApp.RegisterMany(type => type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(ZeroBaseModel)), viewmodelsAreTransient);
 }
Пример #17
0
 public async Task Setup()
 {
     await ZeroApp.UseTest(DependencyHelper.ServiceCollection);
 }
Пример #18
0
 /// <summary>
 /// Register all content page
 /// </summary>
 public static void RegisterPages()
 {
     ZeroApp.RegisterMany(type => type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(ContentPage)));
 }