public void TestConstructorFilteredSubscription() { var objectUnderTest = new TestTopicViewModelBase( _ownerMock.Object, _itemMock.Object, new List <Subscription> { _orphanSubscription }); Assert.AreEqual(0, objectUnderTest.Children.Count); }
public void TestOpenBrowser() { const string targetUrl = "http://target/url"; var objectUnderTest = new TestTopicViewModelBase( _ownerMock.Object, _itemMock.Object, new List <Subscription>()); objectUnderTest.OpenBrowser(targetUrl); _ownerMock.Verify(o => o.OpenBrowser(targetUrl), Times.Once); }
public void TestConstrutorEmptySubscriptions() { var objectUnderTest = new TestTopicViewModelBase(_ownerMock.Object, _itemMock.Object, new List <Subscription>()); Assert.AreEqual(_ownerMock.Object.DataSource, objectUnderTest.DataSource); Assert.AreEqual(_ownerMock.Object.Context, objectUnderTest.Context); Assert.AreEqual((object)_itemMock.Object, objectUnderTest.Item); Assert.AreEqual(((ICloudExplorerItemSource)objectUnderTest).Item, objectUnderTest.Item); objectUnderTest.AssetOwnerEquals(_ownerMock.Object); Assert.AreEqual(0, objectUnderTest.Children.Count); }
public void TestConstructorChildSubscription() { var objectUnderTest = new TestTopicViewModelBase( _ownerMock.Object, _itemMock.Object, new List <Subscription> { _childSubscription }); List <SubscriptionViewModel> subscriptions = objectUnderTest.Children.Cast <SubscriptionViewModel>().ToList(); CollectionAssert.AreEquivalent( new[] { MockSubscriptionLeafName }, subscriptions.Select(s => s.Caption).ToList()); }
public void TestConstructorChildSubscription() { var objectUnderTest = new TestTopicViewModelBase( _ownerMock.Object, _itemMock.Object, new List <Subscription> { _childSubscription }); Assert.AreEqual(1, objectUnderTest.Children.Count); var subscriptions = objectUnderTest.Children.OfType <SubscriptionViewModel>().ToList(); Assert.AreEqual(1, subscriptions.Count); Assert.IsTrue(subscriptions.Single().Caption == MockSubscriptionLeafName); }
public async Task TestRefreshEmpty() { var objectUnderTest = new TestTopicViewModelBase( _ownerMock.Object, _itemMock.Object, new List <Subscription> { _childSubscription }); _getSubscriptionListSource.SetResult(new List <Subscription>()); await objectUnderTest.Refresh(); Assert.AreEqual(0, objectUnderTest.Children.Count); }
public async Task TestDoubleRefresh() { var objectUnderTest = new TestTopicViewModelBase( _ownerMock.Object, _itemMock.Object, new List <Subscription>()); var firstTask = objectUnderTest.Refresh(); var secondTask = objectUnderTest.Refresh(); _getSubscriptionListSource.SetResult(new List <Subscription>()); await firstTask; await secondTask; _ownerMock.Verify(o => o.DataSource.GetSubscriptionListAsync(), Times.Once); }
public async Task TestRefreshChild() { var objectUnderTest = new TestTopicViewModelBase( _ownerMock.Object, _itemMock.Object, new List <Subscription>()); _getSubscriptionListSource.SetResult(new List <Subscription> { _childSubscription }); await objectUnderTest.Refresh(); List <string> captions = objectUnderTest.Children.Cast <SubscriptionViewModel>().Select(s => s.Caption).ToList(); CollectionAssert.AreEquivalent(new[] { MockSubscriptionLeafName }, captions); }
public async Task TestRefreshChild() { var objectUnderTest = new TestTopicViewModelBase( _ownerMock.Object, _itemMock.Object, new List <Subscription>()); _getSubscriptionListSource.SetResult(new List <Subscription> { _childSubscription }); await objectUnderTest.Refresh(); Assert.AreEqual(1, objectUnderTest.Children.Count); var subscriptions = objectUnderTest.Children.OfType <SubscriptionViewModel>().ToList(); Assert.AreEqual(1, subscriptions.Count); Assert.IsTrue(subscriptions.Single().Caption == MockSubscriptionLeafName); }
public void TestRefreshLoading() { var objectUnderTest = new TestTopicViewModelBase( _ownerMock.Object, _itemMock.Object, new List <Subscription> { _childSubscription }); var refreshTask = objectUnderTest.Refresh(); Assert.IsFalse(refreshTask.IsCompleted); Assert.AreEqual(1, objectUnderTest.Children.Count); var loadingChild = objectUnderTest.Children.Single() as TreeLeaf; Assert.IsNotNull(loadingChild); Assert.IsTrue(loadingChild.IsLoading); Assert.AreEqual(Resources.CloudExplorerPubSubLoadingSubscriptionsCaption, loadingChild.Caption); }
public async Task TestRefreshError() { var objectUnderTest = new TestTopicViewModelBase( _ownerMock.Object, _itemMock.Object, new List <Subscription> { _childSubscription }); _getSubscriptionListSource.SetException(new DataSourceException(MockExceptionMessage)); await objectUnderTest.Refresh(); Assert.AreEqual(1, objectUnderTest.Children.Count); var errorChild = objectUnderTest.Children.Single() as TreeLeaf; Assert.IsNotNull(errorChild); Assert.IsTrue(errorChild.IsError); Assert.AreEqual(Resources.CloudExplorerPubSubListSubscriptionsErrorCaption, errorChild.Caption); }