Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            AndroidApplication = Application as AndroidApplication;
            AndroidApplication.Logger.Debug(() => $"ExampleActivity:OnCreate");

            base.OnCreate(savedInstanceState);

            // Set our view from the layout resource
            SetContentView(Resource.Layout.activity_example);

            var factory = AndroidApplication.IocContainer.Resolve <ViewModelFactory>();

            ViewModel = new ViewModelProvider(this, factory).Get(Java.Lang.Class.FromType(typeof(ExampleViewModel))) as ExampleViewModel;
            Lifecycle.AddObserver(ViewModel);
            SetupLiveDataViewModelObservers();
            SetupViewModelObservers();

            ViewModel.Initialise();

            AndroidApplication.Logger.Debug(() => $"ExampleActivity:OnCreate - end");
        }
        public void Initialise_Sets_Title()
        {
            ViewModel.Initialise();

            Assert.Equal("Observed Title", LastSetTitle);
        }