public Task TestExistsAsync()
        {
            var storageController = new Mock <IStorageController>();
            var mockedStorage     = new Mock <IStorageDictionary <string, object> >();
            var controller        = new AVCurrentUserController(storageController.Object);
            var user = new AVUser();

            storageController.Setup(c => c.LoadAsync()).Returns(Task.FromResult(mockedStorage.Object));

            bool contains = false;

            mockedStorage.Setup(s => s.AddAsync("CurrentUser", It.IsAny <object>())).Callback(() => {
                contains = true;
            }).Returns(Task.FromResult <object>(null)).Verifiable();

            mockedStorage.Setup(s => s.RemoveAsync("CurrentUser")).Callback(() => {
                contains = false;
            }).Returns(Task.FromResult <object>(null)).Verifiable();

            mockedStorage.Setup(s => s.ContainsKey("CurrentUser")).Returns(() => contains);

            return(controller.SetAsync(user, CancellationToken.None).OnSuccess(_ => {
                Assert.AreEqual(user, controller.CurrentUser);

                return controller.ExistsAsync(CancellationToken.None);
            }).Unwrap()
                   .OnSuccess(t => {
                Assert.IsTrue(t.Result);

                controller.ClearFromMemory();
                return controller.ExistsAsync(CancellationToken.None);
            }).Unwrap()
                   .OnSuccess(t => {
                Assert.IsTrue(t.Result);

                controller.ClearFromDisk();
                return controller.ExistsAsync(CancellationToken.None);
            }).Unwrap()
                   .OnSuccess(t => {
                Assert.IsFalse(t.Result);
                mockedStorage.Verify();
            }));
        }
        public Task TestLogOut()
        {
            var storageController = new Mock <IStorageController>(MockBehavior.Strict);
            var controller        = new AVCurrentUserController(storageController.Object);
            var user = new AVUser();

            return(controller.SetAsync(user, CancellationToken.None).OnSuccess(_ => {
                Assert.AreEqual(user, controller.CurrentUser);
                return controller.ExistsAsync(CancellationToken.None);
            }).Unwrap()
                   .OnSuccess(t => {
                Assert.IsTrue(t.Result);

                return controller.LogOutAsync(CancellationToken.None);
            }).Unwrap().OnSuccess(_ => controller.GetAsync(CancellationToken.None)).Unwrap()
                   .OnSuccess(t => {
                Assert.IsNull(t.Result);

                return controller.ExistsAsync(CancellationToken.None);
            }).Unwrap()
                   .OnSuccess(t => {
                Assert.IsFalse(t.Result);
            }));
        }