public void Simple() { var service = new PushService { RequestBuilder = RequestBuilderHelper.Build() }; var pushNotification = new PushNotificationRequest { DeviceTokens = new List<string> { RemoteSettings.AppleDeviceId }, Payload = new PushPayload { Alert = "Alert" }, CustomData = new Dictionary<string, string> { {"Key", "Value"} } }; var asyncTestHelper = new AsyncTestHelper(); service.Execute(pushNotification, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); }
public void Simple() { var service = new PushService { RequestBuilder = RequestBuilderHelper.Build() }; var request = new PushNotificationRequest { DeviceTokens = new List<string> { "BadToken" }, Payload = new PushPayload { Alert = "Alert" }, }; Exception exception = null; try { var asyncTestHelper = new AsyncTestHelper(); service.Execute(request, respone => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); } catch (Exception e) { exception = e; } var remoteException = exception as RemoteException; Assert.IsNotNull(remoteException); Assert.AreEqual("{\"error_code\": 40001, \"details\": {\"device_tokens.0.device_token\": [\"device_token contains an invalid device token: BADTOKEN\"]}, \"error\": \"Data validation error\"}", remoteException.Message); }
public void ItGetsAnAtoZListingForTheLetterV() { var letter = "v"; var aToZArticle = new List <AtoZ> { new AtoZ("V atoztitle 1", "atozslug1", "atozteaser1", "article", new List <string> { "V atoztitle" }), new AtoZ("V atoztitle 2", "atozslug2", "atozteaser2", "article", new List <string> { "V atoztitle" }), new AtoZ("V atoztitle 3", "atozslug3", "atozteaser3", "article", new List <string> { "V atoztitle" }) }; var aToZShowcase = new List <AtoZ> { new AtoZ("V atoztitle 1", "atozslug1", "atozteaser1", "showcase", new List <string> { "V atoztitle" }), new AtoZ("V atoztitle 2", "atozslug2", "atozteaser2", "showcase", new List <string> { "V atoztitle" }), new AtoZ("V atoztitle 3", "atozslug3", "atozteaser3", "showcase", new List <string> { "V atoztitle" }) }; var aToZTopic = new List <AtoZ> { new AtoZ("V atoztitle 1", "atozslug1", "atozteaser1", "topic", new List <string> { "V atoztitle" }), new AtoZ("V atoztitle 2", "atozslug2", "atozteaser2", "topic", new List <string> { "V atoztitle" }), new AtoZ("V atoztitle 3", "atozslug3", "atozteaser3", "topic", new List <string> { "V atoztitle" }) }; _aToZFactory.Setup(o => o.ToModel(It.IsAny <ContentfulAtoZ>())) .Returns(new AtoZ("Vintage Village turns 6 years old", "vintage-village-turns-6-years-old", "The vintage village turned 6 with a great reception", "article", new List <string>())); var repository = new AtoZRepository(_config, _contentfulClientManager.Object, _aToZFactory.Object, null, _cache.Object, _configuration.Object, _logger.Object); _cache.Setup(o => o.GetFromCacheOrDirectlyAsync(It.Is <string>(s => s == $"atoz-article-{letter}"), It.IsAny <Func <Task <List <AtoZ> > > >(), It.Is <int>(s => s == 60))).ReturnsAsync(aToZArticle); _cache.Setup(o => o.GetFromCacheOrDirectlyAsync(It.Is <string>(s => s == $"atoz-topic-{letter}"), It.IsAny <Func <Task <List <AtoZ> > > >(), It.Is <int>(s => s == 60))).ReturnsAsync(aToZTopic); _cache.Setup(o => o.GetFromCacheOrDirectlyAsync(It.Is <string>(s => s == $"atoz-showcase-{letter}"), It.IsAny <Func <Task <List <AtoZ> > > >(), It.Is <int>(s => s == 60))).ReturnsAsync(aToZShowcase); var response = AsyncTestHelper.Resolve(repository.Get(letter)); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var aToZListing = response.Get <List <AtoZ> >(); aToZListing.Count.Should().Be(9); }
public async void Unable_to_login_if_password_is_incorrect() { var e = await AsyncTestHelper.ThrowsAsync <MemberApiProxyException>( () => PlayerWebservice.Login(CreateLoginRequest(_registrationData.Username, "some invalid password"))); Assert.IsNotEmpty(e.Exception.ErrorMessage); Assert.AreEqual(PlayerAccountResponseCode.UsernamePasswordCombinationIsNotValid.ToString(), e.Exception.ErrorCode); }
public async void Unable_to_login_if_username_does_not_exist() { var e = await AsyncTestHelper.ThrowsAsync <MemberApiProxyException>( () => PlayerWebservice.Login(CreateLoginRequest("notExistingUsername", _registrationData.Password))); Assert.IsNotEmpty(e.Exception.ErrorMessage); Assert.That(e.Exception.ErrorCode, Is.EqualTo(PlayerAccountResponseCode.UsernamePasswordCombinationIsNotValid.ToString())); }
public void GetUpdatedRedirects_NoBusinessId_ReturnNotFound() { var repository = new RedirectsRepository(_contentfulClientManager.Object, _createConfig.Object, new RedirectBusinessIds(new List <string>()), _contenfulFactory.Object, _shortUrlRedirects, _legacyUrlRedirects); var response = AsyncTestHelper.Resolve(repository.GetUpdatedRedirects()); response.StatusCode.Should().Be(HttpStatusCode.NotFound); }
public void ShouldGetEventForACategoryAndDate() { // Arrange var dateFrom = new DateTime(2016, 07, 28); var dateTo = new DateTime(2017, 02, 15); _mockTimeProvider.Setup(o => o.Now()).Returns(new DateTime(2017, 08, 08)); var contentfulCategory1 = new ContentfulEventCategory { Name = "Category 1", Slug = "category-1" }; var contentfulCategory2 = new ContentfulEventCategory { Name = "Category 2", Slug = "category-2" }; var contentfulCategory3 = new ContentfulEventCategory { Name = "Category 3", Slug = "category-3" }; var event1 = new ContentfulEventBuilder().EventCategoryList(new List <ContentfulEventCategory>() { contentfulCategory1 }) .EventDate(new DateTime(2017, 08, 01)) .Build(); var event2 = new ContentfulEventBuilder().EventCategoryList(new List <ContentfulEventCategory>() { contentfulCategory2 }) .EventDate(new DateTime(2016, 08, 01)) .Build(); var event3 = new ContentfulEventBuilder().EventCategoryList(new List <ContentfulEventCategory>() { contentfulCategory3 }) .EventDate(new DateTime(2016, 08, 01)) .Build(); var events = new List <ContentfulEvent> { event1, event2, event3 }; _eventCategoryFactory.Setup(o => o.ToModel(contentfulCategory1)).Returns(new EventCategory("Category 1", "category-1", "icon1")); _eventCategoryFactory.Setup(o => o.ToModel(contentfulCategory2)).Returns(new EventCategory("Category 2", "category-2", "icon2")); _eventCategoryFactory.Setup(o => o.ToModel(contentfulCategory3)).Returns(new EventCategory("Category 3", "category-3", "icon3")); _cacheWrapper.Setup(o => o.GetFromCacheOrDirectlyAsync(It.Is <string>(s => s == "event-all"), It.IsAny <Func <Task <IList <ContentfulEvent> > > >(), It.Is <int>(s => s == 60))).ReturnsAsync(events); // Act var response = AsyncTestHelper.Resolve(_repository.Get(dateFrom, dateTo, "Category 3", 0, null, null, null, 0, 0)); // Assert response.StatusCode.Should().Be(HttpStatusCode.OK); var eventCalender = response.Get <EventCalender>(); eventCalender.Events.Should().HaveCount(1); }
public void GivenThereIsItemInTheContentResponse_ItReturnsOKResponseWithTheContentOfStartPage() { // Arrange string slug = "startpage_slug"; var ContentfulStartPage = new ContentfulStartPageBuilder().Slug(slug).Build(); var collection = new ContentfulCollection <ContentfulStartPage>(); collection.Items = new List <ContentfulStartPage> { ContentfulStartPage }; List <Alert> _alerts = new List <Alert> { new Alert("title", "subHeading", "body", "severity", new DateTime(0001, 1, 1, 0, 0, 0, DateTimeKind.Utc), new DateTime(9999, 9, 9, 0, 0, 0, DateTimeKind.Utc), string.Empty, false) }; List <Alert> _inlineAlerts = new List <Alert> { new Alert("title", "subHeading", "body", "severity", new DateTime(0001, 1, 1, 0, 0, 0, DateTimeKind.Utc), new DateTime(9999, 9, 9, 0, 0, 0, DateTimeKind.Utc), string.Empty, false) }; var startPageItem = new StartPage("Start Page", "startPageSlug", "this is a teaser", "This is a summary", "An upper body", "Start now", "http://start.com", "Lower body", "image.jpg", "icon", new List <Crumb> { new Crumb("title", "slug", "type") }, _alerts, _inlineAlerts, DateTime.MinValue, DateTime.MaxValue); var builder = new QueryBuilder <ContentfulRedirect>().ContentTypeIs("startPage").FieldEquals("fields.slug", slug).Include(3); _client.Setup(o => o.GetEntries(It.Is <QueryBuilder <ContentfulStartPage> >(q => q.Build() == builder.Build()), It.IsAny <CancellationToken>())).ReturnsAsync(collection); _startPageFactory.Setup(o => o.ToModel(It.IsAny <ContentfulStartPage>())).Returns(startPageItem); var response = AsyncTestHelper.Resolve(_repository.GetStartPage(slug)); var startPage = response.Get <StartPage>(); // Act // Assert response.StatusCode.Should().Be(HttpStatusCode.OK); startPage.Title.Should().Be("Start Page"); startPage.Slug.Should().Be("startPageSlug"); startPage.Teaser.Should().Be("this is a teaser"); startPage.Summary.Should().Be("This is a summary"); startPage.UpperBody.Should().Be("An upper body"); startPage.FormLink.Should().Be("http://start.com"); startPage.FormLinkLabel.Should().Be("Start now"); startPage.LowerBody.Should().Be("Lower body"); startPage.BackgroundImage.Should().Be("image.jpg"); startPage.Icon.Should().Be("icon"); startPage.Breadcrumbs.Should().HaveCount(1); startPage.Alerts.Should().BeEquivalentTo(_alerts); startPage.AlertsInline.Should().BeEquivalentTo(_inlineAlerts); }
public async Task TearDownAsync() { // Wait for pending operations so the repository is not deleted while operations run in the background await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); //// _provider is a singleton and must not be disposed _repo1.Dispose(); _repo2.Dispose(); _repo3.Dispose(); }
public async Task Scenario() { await TestDbContext.ExecAsync(async context => { var set = context.Set <DataItem>(); set.AddRange(AsyncTestHelper.CreateTestData(() => new DataItem())); await context.SaveChangesAsync(); await AsyncTestHelper.RunAsync(set); }); }
public async Task FileAndForgetFilterCanAllowExceptions() { using var helper = new ThreadExceptionHelper(); var ex = new Exception(); ThrowExceptionAsync(ex).FileAndForget(fileOnlyIf: e => e == ex); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.AreSame(ex, helper.Exception); }
public void GetsProfileForProfileSlug() { const string slug = "a-slug"; var contentfulTopic = new ContentfulProfileBuilder().Slug(slug).Build(); var collection = new ContentfulCollection <ContentfulProfile>(); collection.Items = new List <ContentfulProfile> { contentfulTopic }; var profile = new Profile { Title = "title", Slug = "slug", Subtitle = "subtitle", Quote = "quote", Image = "image", Body = "body", Breadcrumbs = new List <Crumb> { new Crumb("title", "slug", "type") }, Alerts = new List <Alert> { new Alert("title", "subheading", "body", "severity", DateTime.MinValue, DateTime.MaxValue, "slug", false) }, TriviaSubheading = "trivia heading", TriviaSection = new List <Trivia>(), InlineQuotes = new List <InlineQuote>(), Author = "author", Subject = "subject" }; var builder = new QueryBuilder <ContentfulProfile>().ContentTypeIs("profile").FieldEquals("fields.slug", slug).Include(1); _client.Setup(o => o.GetEntries(It.Is <QueryBuilder <ContentfulProfile> >(q => q.Build() == builder.Build()), It.IsAny <CancellationToken>())).ReturnsAsync(collection); _profileFactory.Setup(o => o.ToModel(contentfulTopic)).Returns(profile); var response = AsyncTestHelper.Resolve(_repository.GetProfile(slug)); response.StatusCode.Should().Be(HttpStatusCode.OK); var responseProfile = response.Get <Profile>(); responseProfile.Should().BeEquivalentTo(profile); }
public void BuildServerType_should_contain_only_None_if_not_build_server_plugins_found() { RunFormTest( async form => { await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.AreEqual(1, _settingsPage.GetTestAccessor().BuildServerType.Items.Count); Assert.AreEqual(0, _settingsPage.GetTestAccessor().BuildServerType.SelectedIndex); }); }
public void ShouldGet404IfContentNotFound() { _mockTimeProvider.Setup(o => o.Now()).Returns(new DateTime(2017, 01, 01)); _contentfulClient.Setup(o => o.GetEntries(It.IsAny <QueryBuilder <Event> >(), It.IsAny <CancellationToken>())).ReturnsAsync(new ContentfulCollection <Event>()); var response = AsyncTestHelper.Resolve(_repository.Get(null, null, null, 0, null, null, null, 0, 0)); response.StatusCode.Should().Be(HttpStatusCode.NotFound); response.Error.Should().Be("No events found"); }
public async Task FileAndForgetReportsThreadException() { using var helper = new ThreadExceptionHelper(); var ex = new Exception(); ThrowExceptionAsync(ex).FileAndForget(); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.AreSame(ex, helper.Exception); }
public void GetsA404ForANotFoundEventItem() { _mockTimeProvider.Setup(o => o.Now()).Returns(new DateTime(2015, 08, 5)); _cacheWrapper.Setup(o => o.GetFromCacheOrDirectlyAsync(It.Is <string>(s => s == "event-all"), It.IsAny <Func <Task <IList <ContentfulEvent> > > >(), It.Is <int>(s => s == 60))).ReturnsAsync(new List <ContentfulEvent>()); var response = AsyncTestHelper.Resolve(_repository.GetEvent("event-not-found", new DateTime(2017, 4, 1))); response.StatusCode.Should().Be(HttpStatusCode.NotFound); response.Error.Should().Be("No event found for 'event-not-found'"); }
public async Task FileAndForgetFilterCanIgnoreExceptions() { using var helper = new ThreadExceptionHelper(); var ex = new Exception(); ThrowExceptionAsync(ex).FileAndForget(fileOnlyIf: e => e != ex); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.Null(helper.Exception, helper.Message); }
public void HandlesSuccessFromRemote() { _fakeHttpClient.For("a url") .Return(HttpResponse.Successful("some data")); var httpClient = new LoggingHttpClient(_fakeHttpClient, _fakeLogger); HttpResponse response = AsyncTestHelper.Resolve(httpClient.Get("a url")); Assert.Equal("Querying: a url", _fakeLogger.InfoMessage); Assert.Equal("Response: " + response, _fakeLogger.DebugMessage); Assert.Null(_fakeLogger.ErrorMessage); }
public void Tags() { var service = new DeleteTagService { RequestBuilder = RequestBuilderHelper.Build() }; var helper = new AsyncTestHelper(); var request = new DeleteTagRequest {Tag = "myTag"}; service.Execute(request, response => helper.Callback(null), helper.HandleException); helper.Wait(); }
public void HandlesException() { var handler = new ResponseHandler(_fakeLogger); var result = AsyncTestHelper.Resolve(handler.Get(() => { throw new Exception("error"); })); Assert.Equal("An unexpected error occurred while performing the get operation", _fakeLogger.ErrorMessage); Assert.Equal(500, (result as StatusCodeResult).StatusCode); }
public void GetsAllNewsItemsWhenNoNewsroomIsPresent() { _mockTimeProvider.Setup(o => o.Now()).Returns(new DateTime(2016, 08, 5)); var newsRoom = new Newsroom(new List <Alert> { }, true, ""); _newsRoomContentfulFactory.Setup(o => o.ToModel(It.IsAny <ContentfulNewsRoom>())).Returns(newsRoom); var news = new News(Title, Slug, Teaser, Purpose, Image, ThumbnailImage, Body, _sunriseDate, _sunsetDate, _crumbs, _alerts, null, new List <Document>(), _newsCategories); _newsContentfulFactory.Setup(o => o.ToModel(It.IsAny <ContentfulNews>())).Returns(news); var newsListCollection = new ContentfulCollection <ContentfulNews>(); newsListCollection.Items = new List <ContentfulNews> { new ContentfulNewsBuilder().Title("Another news article").Slug("another-news-article").Teaser("This is another news article").SunriseDate(new DateTime(2016, 06, 30, 23, 0, 0, DateTimeKind.Utc)).SunsetDate(new DateTime(2017, 11, 22, 23, 0, 0, DateTimeKind.Utc)).Build(), new ContentfulNewsBuilder().Title("This is the news").Slug("news-of-the-century").Teaser("Read more for the news").SunriseDate(new DateTime(2016, 08, 24, 23, 30, 0, DateTimeKind.Utc)).SunsetDate(new DateTime(2016, 08, 23, 23, 0, 0, DateTimeKind.Utc)).Build(), }; _client.Setup(o => o.GetEntries <ContentfulNews>( It.Is <string>(q => q.Contains(new QueryBuilder <ContentfulNews>().ContentTypeIs("news").Include(1).Build())), It.IsAny <CancellationToken>())).ReturnsAsync(newsListCollection); _videoRepository.Setup(o => o.Process(It.IsAny <string>())).Returns("The news"); _cacheWrapper.Setup(_ => _.GetFromCacheOrDirectlyAsync(It.Is <string>(s => s == "news-all"), It.IsAny <Func <Task <IList <ContentfulNews> > > >(), It.Is <int>(s => s == 60))).ReturnsAsync(newsListCollection.Items.ToList()); _cacheWrapper.Setup(_ => _.GetFromCacheOrDirectlyAsync(It.Is <string>(s => s == "newsroom"), It.IsAny <Func <Task <ContentfulNewsRoom> > >(), It.Is <int>(s => s == 60))).ReturnsAsync(new ContentfulNewsRoom { Title = "test" }); var response = AsyncTestHelper.Resolve(_repository.Get(null, null, null, null)); response.StatusCode.Should().Be(HttpStatusCode.OK); var newsroom = response.Get <Newsroom>(); newsroom.Alerts.Count.Should().Be(0); newsroom.News.Count.Should().Be(2); newsroom.News.First().Title.Should().Be(Title); newsroom.News.First().Body.Should().Be(Body); newsroom.News.First().Slug.Should().Be(Slug); newsroom.News.First().Teaser.Should().Be(Teaser); newsroom.News.First().SunriseDate.Should().Be(_sunriseDate); newsroom.News.First().SunsetDate.Should().Be(_sunsetDate); newsroom.News.First().Image.Should().Be(Image); newsroom.News.First().ThumbnailImage.Should().Be(ThumbnailImage); newsroom.News.First().Breadcrumbs.Should().BeEquivalentTo(_crumbs); newsroom.News.First().Alerts.Should().BeEquivalentTo(_alerts); newsroom.Dates.Should().HaveCount(1); newsroom.Dates[0].Should().HaveMonth(8); newsroom.Dates[0].Should().HaveYear(2016); }
public async Task Scenario() { await UnitOfWorkHelper.ExecAsync(async uow => { foreach (var i in AsyncTestHelper.CreateTestData(() => new DataItem())) { uow.Save(i); } uow.CommitChanges(); await AsyncTestHelper.RunAsync(uow.Query <DataItem>()); }); }
public void BuildServerType_should_contain_discovered_build_server_plugins() { RunFormTest( async form => { await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.AreEqual(/* default None + GenericBuildServerMock */ 2, _settingsPage.GetTestAccessor().BuildServerType.Items.Count); Assert.AreEqual(0, _settingsPage.GetTestAccessor().BuildServerType.SelectedIndex); Assert.AreEqual("GenericBuildServerMock", _settingsPage.GetTestAccessor().BuildServerType.Items[1]); }); }
public async Task FileAndForgetIgnoresCancellationExceptions() { using ThreadExceptionHelper helper = new(); Form form = new(); form.Dispose(); YieldOntoControlMainThreadAsync(form).FileAndForget(); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.Null(helper.Exception, helper.Message); }
public void ShouldReturnNotFoundIfNoEventCategoryFound() { var collection = new ContentfulCollection <ContentfulEventCategory>(); collection.Items = new List <ContentfulEventCategory>(); _cacheWrapper.Setup(o => o.GetFromCacheOrDirectlyAsync(It.Is <string>(s => s == "event-categories-content-type"), It.IsAny <Func <Task <List <EventCategory> > > >(), It.Is <int>(s => s == 60))).ReturnsAsync(new List <EventCategory>()); // Act var response = AsyncTestHelper.Resolve(_repository.GetEventCategories()); response.StatusCode.Should().Be(HttpStatusCode.NotFound); }
public async Task FileAndForgetFilterIgnoresCancellationExceptions() { using var helper = new ThreadExceptionHelper(); var form = new Form(); form.Dispose(); YieldOntoControlMainThreadAsync(form).FileAndForget(fileOnlyIf: ex => true); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.Null(helper.Exception, helper.Message); }
public void FileManagerViewModel() { var viewModel = new GetImageViewModel( MockRepository.GenerateStub <IScannerManager>(), MockRepository.GenerateStub <IScreen>()); AsyncTestHelper.ExecuteOperationTest( () => viewModel, vm => vm.WhenAny(x => x.IsBusy, x => x.Value).Where(isBusy => !isBusy).Skip(1), vm => Assert.That(vm.Image, Is.Not.Null), vm => vm.ScanningCommand.Execute(null), 1000, () => Assert.Fail("The test is timeout")); }
public void ItReturnsBreadcrumbs() { // Arrange const string slug = "unit-test-showcase-crumbs"; var crumb = new Crumb("title", "slug", "type"); var collection = new ContentfulCollection <ContentfulShowcase>(); var rawShowcase = new ContentfulShowcaseBuilder().Slug(slug) .Breadcrumbs(new List <ContentfulReference>() { new ContentfulReference() { Title = crumb.Title, Slug = crumb.Title, Sys = new SystemProperties() { Type = "Entry" } }, }) .Build(); collection.Items = new List <ContentfulShowcase> { rawShowcase }; var builder = new QueryBuilder <ContentfulShowcase>().ContentTypeIs("showcase").FieldEquals("fields.slug", slug).Include(3); _contentfulClient.Setup(o => o.GetEntries(It.Is <QueryBuilder <ContentfulShowcase> >(q => q.Build() == builder.Build()), It.IsAny <CancellationToken>())) .ReturnsAsync(collection); _crumbFactory.Setup(o => o.ToModel(It.IsAny <ContentfulReference>())).Returns(crumb); var rawEvent = new ContentfulEventBuilder().Slug(slug).EventDate(new DateTime(2017, 4, 1)).Build(); var events = new List <ContentfulEvent> { rawEvent }; _cacheWrapper.Setup(o => o.GetFromCacheOrDirectlyAsync(It.Is <string>(s => s == "event-all"), It.IsAny <Func <Task <IList <ContentfulEvent> > > >(), It.Is <int>(s => s == 60))).ReturnsAsync(events); var modelledEvent = new Event("title", "event-slug", "", "", "", "", "", "", DateTime.MaxValue, "", "", 1, EventFrequency.None, null, "", null, new List <string>(), null, false, "", DateTime.MinValue, new List <string>(), null, null, new List <EventCategory> { new EventCategory("event", "slug", "icon") }, null, null, null, null); _eventFactory.Setup(e => e.ToModel(It.IsAny <ContentfulEvent>())).Returns(modelledEvent); // Act var response = AsyncTestHelper.Resolve(_repository.GetShowcases(slug)); // Assert response.StatusCode.Should().Be(HttpStatusCode.OK); var showcase = response.Get <Showcase>(); showcase.Breadcrumbs.First().Should().Be(crumb); }
public void Simple() { var service = new GetRegistrationService { RequestBuilder = RequestBuilderHelper.Build() }; var helper = new AsyncTestHelper<GetRegistrationResponse>(); var request = new GetRegistrationRequest { PushId = RemoteSettings.AndroidPushId }; service.Execute(request, helper.Callback, helper.HandleException); helper.Wait(); }
public void ShouldReturnNotFoundIfNoGroupCategoryFound() { var collection = new ContentfulCollection <ContentfulGroupCategory>(); collection.Items = new List <ContentfulGroupCategory>(); _contentfulClient.Setup(o => o.GetEntries(It.IsAny <QueryBuilder <ContentfulGroupCategory> >(), It.IsAny <CancellationToken>())) .ReturnsAsync(collection); // Act var response = AsyncTestHelper.Resolve(_repository.GetGroupCategories()); response.StatusCode.Should().Be(HttpStatusCode.NotFound); }
public void Should_display_branch_and_no_remote_info_in_statusbar() { _referenceRepository.CheckoutMaster(); RunFormTest(async form => { await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); var currentBranchNameLabelStatus = form.GetTestAccessor().CurrentBranchNameLabelStatus; var remoteNameLabelStatus = form.GetTestAccessor().RemoteNameLabelStatus; Assert.AreEqual("master →", currentBranchNameLabelStatus.Text); Assert.AreEqual("(remote not configured)", remoteNameLabelStatus.Text); }); }
public void Should_display_branch_and_remote_info_in_statusbar() { _referenceRepository.CreateRemoteForMasterBranch(); RunFormTest(form => { AsyncTestHelper.WaitForPendingOperations(AsyncTestHelper.UnexpectedTimeout); var currentBranchNameLabelStatus = form.GetTestAccessor().CurrentBranchNameLabelStatus; var remoteNameLabelStatus = form.GetTestAccessor().RemoteNameLabelStatus; Assert.AreEqual("master →", currentBranchNameLabelStatus.Text); Assert.AreEqual("origin/master", remoteNameLabelStatus.Text); }); }
public void editFileToolStripMenuItem_Click_no_selection_should_not_throw() { RunFormTest(async form => { await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); form.GetTestAccessor().UnstagedList.ClearSelected(); var editFileToolStripMenuItem = form.GetTestAccessor().EditFileToolStripMenuItem; // asserting by the virtue of not crashing editFileToolStripMenuItem.PerformClick(); }); }
public async Task Scenario() { await SessionFactoryHelper.ExecAsync(async session => { using (var tx = session.BeginTransaction()) { foreach (var i in AsyncTestHelper.CreateTestData(() => new DataItem())) { session.Save(i); } await tx.CommitAsync(); } await AsyncTestHelper.RunAsync(session.Query <DataItem>()); }); }
public void Tags() { var service = new GetTagsService { RequestBuilder = RequestBuilderHelper.Build() }; var helper = new AsyncTestHelper<GetTagsResponse>(); service.Execute(helper.Callback, helper.HandleException); helper.Wait(); foreach (var tag in helper.Response.Tags) { Debug.WriteLine(tag); } }
public void TagToDevice() { var service = new AddTagToDeviceService { RequestBuilder = RequestBuilderHelper.Build() }; var asyncTestHelper = new AsyncTestHelper(); var request = new AddTagToDeviceRequest { DeviceToken = RemoteSettings.AppleDeviceId, Tag = "africa" }; service.Execute(request, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); }
public void Tags() { var service = new RemoveTagFromDeviceService { RequestBuilder = RequestBuilderHelper.Build() }; var helper = new AsyncTestHelper(); var request = new RemoveTagFromDeviceRequest { DeviceToken = "DeviceId", TagToRemove = "tag1434" }; service.Execute(request, response => helper.Callback(null), helper.HandleException); helper.Wait(); }
public void Tags() { var service = new AddRegistrationService { RequestBuilder = RequestBuilderHelper.Build() }; var registration = new AddRegistrationRequest { PushId = RemoteSettings.AndroidPushId, Tags = new List<string> {"bangladesh"} }; var asyncTestHelper = new AsyncTestHelper(); service.Execute(registration, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); }
public void Integration() { var service = new GetRegistrationsService { RequestBuilder = RequestBuilderHelper.Build() }; var helper = new AsyncTestHelper<GetRegistrationsResponse>(); var request = new GetRegistrationsRequest(); service.Execute(request, helper.Callback, helper.HandleException); helper.Wait(); var response = helper.Response; foreach (var device in response.Devices) { Debug.WriteLine(device.DeviceToken); } }
public void NotFound() { var service = new GetRegistrationService { RequestBuilder = RequestBuilderHelper.Build() }; var helper = new AsyncTestHelper<GetRegistrationResponse>(); var getRegistrationRequest = new GetRegistrationRequest { DeviceToken = "foo" }; service.Execute(getRegistrationRequest, helper.Callback, helper.HandleException); helper.Wait(); Assert.IsNull(helper.Response); }
public void Simple() { var service = new PushService { RequestBuilder = RequestBuilderHelper.Build() }; var pushNotification = new PushNotificationRequest { PushIds = new List<string> {RemoteSettings.AndroidPushId}, Payload = new PushPayload { Alert = "Alert 2" } }; var asyncTestHelper = new AsyncTestHelper(); service.Execute(pushNotification, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); }
public void Simple() { var service = new ModifyTagService { RequestBuilder = RequestBuilderHelper.Build() }; var tokens = new ModifyTagRequest { Tag = "myTag", AddDeviceTokens = new List<string> { RemoteSettings.AppleDeviceId }, }; var asyncTestHelper = new AsyncTestHelper(); service.Execute(tokens, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); }
public void TagsForDevices() { var service = new GetTagsForDeviceService { RequestBuilder = RequestBuilderHelper.Build() }; var helper = new AsyncTestHelper<GetTagsForDeviceResponse>(); var request = new GetTagsForDeviceRequest {DeviceToken = RemoteSettings.AppleDeviceId}; service.Execute(request, helper.Callback, helper.HandleException); helper.Wait(); foreach (var tag in helper.Response.Tags) { Debug.WriteLine(tag); } }
public void ToTag() { var service = new PushService { RequestBuilder = RequestBuilderHelper.Build() }; var pushNotification = new PushNotificationRequest { Tags = new List<string> {"africa"}, Payload = new PushPayload { Alert = "Alert 2" } }; var asyncTestHelper = new AsyncTestHelper(); service.Execute(pushNotification, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); }
public void Simple() { var service = new BroadcastService { RequestBuilder = RequestBuilderHelper.Build() }; var broadcastNotification = new BroadcastNotificationRequest { Payload = new PushPayload { Alert = "Alert 2", Badge = Badge.Increment() } }; var asyncTestHelper = new AsyncTestHelper(); service.Execute(broadcastNotification, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); }
public void ToAlias() { var service = new PushService { RequestBuilder = RequestBuilderHelper.Build() }; var random = new Random(); var pushNotification = new PushNotificationRequest { Aliases = new List<string>(new string[] { "1gzod" }), Payload = new PushPayload { Badge = random.Next(100), Alert = "What's up iPhone", } }; var asyncTestHelper = new AsyncTestHelper(); service.Execute(pushNotification, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException); asyncTestHelper.Wait(); }
public void Integration() { var feedbackService = new FeedbackService { RequestBuilder = RequestBuilderHelper.Build() }; var helper = new AsyncTestHelper<FeedbackResponse>(); var request = new FeedbackRequest { Since = 10.Days().Ago() }; feedbackService.Execute(request, helper.Callback, helper.HandleException); helper.Wait(); var deviceFeedbacks = helper.Response.DeviceFeedbacks; Debug.WriteLine(deviceFeedbacks.Count); foreach (var deviceFeedback in deviceFeedbacks) { Debug.WriteLine(deviceFeedback.DeviceToken); Debug.WriteLine(deviceFeedback.MakedInactiveOn); } }
public void Simple() { var service = new GetRegistrationService { RequestBuilder = RequestBuilderHelper.Build() }; var helper = new AsyncTestHelper<GetRegistrationResponse>(); var getRegistrationRequest = new GetRegistrationRequest { DeviceToken = RemoteSettings.AppleDeviceId }; service.Execute(getRegistrationRequest, helper.Callback, helper.HandleException); helper.Wait(); var registration = helper.Response; Debug.WriteLine(registration.Alias); Debug.WriteLine(registration.Badge); Debug.WriteLine(registration.QuietTime.Start); Debug.WriteLine(registration.QuietTime.End); Debug.WriteLine(string.Join(" ", registration.Tags)); Debug.WriteLine(registration.TimeZone); }