public override async Task Init() { await NavService.PushAlertPopupAsync("Loading..."); if (!_hasLoaded) { /* TOGGLE DEMO MODE HERE */ /* DEMO MODE ON */ //For development only -> Demo mode //StateService.SetCurrentUser(DemoUser.UserGeorge.ToModelObj()); //await ((App)Application.Current).SetModeAndSync(true); /* DEMO MODE OFF - BYPASS AZURE AD AUTHENTICATION */ // Hardcode authentication by doing this - robin's dev user - already in the db //await DataDownloadService.InsertOrReplaceAuthenticatedUser(Guid.Parse("b79ed0e3-ddb9-4920-8900-ffc55a73b4b5")); //var user = await DataRetrievalService.GetUserByEmailOrNullAsync("*****@*****.**"); /* DEMO MODE OFF - USE AZURE AD AUTHENTICATION */ //Assuming here that we will be using the same user that just authenticated //now that the user has logged in, we need to see if they are a bingoBuzz user, if not, we can add them //TODO: should probably do a try parse here if we add more providers await DataDownloadService.InsertOrReplaceAuthenticatedUser( StateService.GetAuthEmail(), Guid.Parse(StateService.GetAuthId()), StateService.GetAuthGivenName(), StateService.GetAuthSurName() ); var user = await DataRetrievalService.GetUserByEmailOrNullAsync(StateService.GetAuthEmail()); /* END TOGGLE DEMO MODE HERE */ if (user != null) { StateService.SetCurrentUser(user); } else { string whatHappened = "Can't find this BingoBuzz user!"; LoggingService.Error(whatHappened, LogMessageType.Instance.Info_Synchronization); throw new Exception(whatHappened); } await((App)Application.Current).SetModeAndSync(user.UserId, false); //Load the contents of the welcome page Meetings = (await DataRetrievalService.GetMeetingsAsync()).ToObservableCollection(); _hasLoaded = true; } await CheckAppCenter(); await NavService.PopAlertPopupsAsync(); }
public void Then_If_It_Is_Not_Successful_An_Exception_Is_Thrown() { //Arrange var response = new HttpResponseMessage { Content = new StringContent(""), StatusCode = HttpStatusCode.BadRequest }; var downloadUrl = "https://test.zip"; var httpMessageHandler = MessageHandler.SetupMessageHandlerMock(response, new Uri(downloadUrl)); var client = new HttpClient(httpMessageHandler.Object); var larsDataDownloadService = new DataDownloadService(client); //Act Assert Assert.ThrowsAsync <HttpRequestException>(() => larsDataDownloadService.GetFileStream(downloadUrl)); }
public async Task Then_The_File_Is_Downloaded_From_The_Url(string content) { //Arrange var response = new HttpResponseMessage { Content = new StreamContent(new MemoryStream(Encoding.UTF8.GetBytes(content))), StatusCode = HttpStatusCode.Accepted }; var downloadUrl = "https://test"; var httpMessageHandler = MessageHandler.SetupMessageHandlerMock(response, new Uri(downloadUrl)); var client = new HttpClient(httpMessageHandler.Object); var larsDataDownloadService = new DataDownloadService(client); //Act var actual = await larsDataDownloadService.GetFileStream(downloadUrl); //Assert var reader = new StreamReader(actual); var actualContent = reader.ReadToEnd(); actualContent.Should().Be(content); }
public void SetUp() { _publishingArea = new Mock <IPublishingAreaRepository>(); _service = new DataDownloadService(_publishingArea.Object); }