public void GetAllCards() { ArtifactClient client = new ArtifactClient(); List <Card> allCards = client.GetAllCards(); Assert.IsNotNull(allCards); }
public void GetCardsBySet() { ArtifactClient client = new ArtifactClient(); CardSet cards = client.GetCardSet("01"); Assert.IsNotNull(cards); }
private void InitClient() { if (m_client == null) { m_client = new ArtifactClient(); m_client.GetAllCards(); } }
public void FindCardById() { int ventriloquyCardId = 10418; ArtifactClient client = new ArtifactClient(); Card card = client.GetCard(ventriloquyCardId); Assert.IsNotNull(card); }
public void FindCardByName() { string cardName = "Phantom assassin"; ArtifactClient client = new ArtifactClient(); Card c = client.GetCard(cardName); Assert.IsNotNull(c); Assert.AreEqual(cardName.ToLower(), c.Names.English.ToLower()); }
public void EncodeDeck() { ArtifactClient client = new ArtifactClient(); string startDeckCode = "ADCJWkTZX05uwGDCRV4XQGy3QGLmqUBg4GQJgGLGgO7AaABR3JlZW4vQmxhY2sgRXhhbXBsZQ__"; DecodedDeck deck = client.DecodeDeck(startDeckCode); string encodedDeckCode = client.EncodeDeck(deck); Assert.AreEqual(startDeckCode, encodedDeckCode); }
public void DecodeDeck() { ArtifactClient client = new ArtifactClient(); DecodedDeck deck = client.DecodeDeck("ADCJQUQI30zuwEYg2ABeF1Bu94BmWIBTEkLtAKlAZakAYmHh0JsdWUvUmVkIEV4YW1wbGU_"); Assert.IsNotNull(deck); Assert.IsNotNull(deck.Heroes); Assert.IsNotNull(deck.Cards); Assert.IsFalse(string.IsNullOrEmpty(deck.Name)); }
private void OnViewLoaded(object sender, RoutedEventArgs e) { m_client = new ArtifactClient(); g_Loading.Visibility = Visibility.Collapsed; //Add all languages to Language ComboBox var allLanguages = Enum.GetValues(typeof(Language)); foreach (Language language in allLanguages) { cb_language.Items.Add(language); } cb_language.SelectedIndex = 0; m_currentLanguage = (Language)allLanguages.GetValue(0); }
public void GetCardArtUrl() { ArtifactClient client = new ArtifactClient(); Card c = client.GetCard("venomancer"); if (c == null) { Assert.Fail(); //Failed because GetCard(name) fails } Enums.ArtType type = Enums.ArtType.Large; string idUrl = client.GetCardArtUrl(c.Id, type); string nameUrl = client.GetCardArtUrl(c.Names.English, type); Assert.IsFalse(string.IsNullOrEmpty(idUrl)); Assert.IsFalse(string.IsNullOrEmpty(nameUrl)); Assert.AreEqual(idUrl, nameUrl); }
public MainWindow() { Logger.OutputInfo($"Program Start - Artifact API {VERSION}"); InitializeComponent(); this.Title += $" {VERSION}"; Closed += OnProgramClosed; Loaded += OnViewLoaded; outputBox.TextChanged += OnOutputPasted; tb_javascriptCopy.GotFocus += OnHaveGotFocus; t_invalidCode.Visibility = Visibility.Collapsed; m_client = new ArtifactClient(); //Load since bug with not loading cards m_client.GetAllCards(); }
public async Task GivenRecord_WhenRoundTrip_ShouldMatch() { ArtifactClient client = TestApplication.GetArtifactClient(); var payload = new Payload("name1", "value1"); DocumentId documentId = new DocumentId("contract:test/testing/payload.json"); Document document = new DocumentBuilder() .SetDocumentId(documentId) .SetData(payload) .Build() .Verify(); await client.Set(document); Document?readDocument = await client.Get(documentId); readDocument.Should().NotBeNull(); readDocument !.Verify(); (document == readDocument).Should().BeTrue(); Payload?readPayload = readDocument !.DeserializeData <Payload>(); readPayload.Should().NotBeNull(); (payload == readPayload).Should().BeTrue(); var search = new QueryParameter { Container = "contract", Filter = "test/testing" }; BatchSet <DatalakePathItem> searchList = await client.Search(search).ReadNext(); searchList.Should().NotBeNull(); searchList.Records.Any(x => x.Name.EndsWith(documentId.Path)).Should().BeTrue(); (await client.Delete(documentId)).Should().BeTrue(); searchList = await client.Search(search).ReadNext(); searchList.Should().NotBeNull(); searchList.Records.Any(x => x.Name.EndsWith(documentId.Path)).Should().BeFalse(); }
public async Task GivenData_WhenRoundTrip_ShouldMatch(string id) { ArtifactClient client = TestApplication.GetArtifactClient(); const string payload = "This is a test"; DocumentId documentId = new DocumentId(id); Document document = new DocumentBuilder() .SetDocumentId(documentId) .SetData(payload) .Build() .Verify(); await client.Set(document); Document?readPayload = await client.Get(documentId); readPayload.Should().NotBeNull(); readPayload !.Verify(); (document == readPayload).Should().BeTrue(); string?payloadText = readPayload !.DeserializeData <string>(); payloadText.Should().Be(payload); var search = new QueryParameter { Container = "contract", Recursive = true }; BatchSet <DatalakePathItem> searchList = await client.Search(search).ReadNext(); searchList.Should().NotBeNull(); searchList.Records.Any(x => x.Name.EndsWith(documentId.Path)).Should().BeTrue(); (await client.Delete(documentId)).Should().BeTrue(); searchList = await client.Search(search).ReadNext(); searchList.Should().NotBeNull(); searchList.Records.Any(x => x.Name.EndsWith(documentId.Path)).Should().BeFalse(); }
public Match(ArtifactClient client) { m_client = client; }
public static List <Match> ParseStringToMatches(string s, ArtifactClient client) { if (string.IsNullOrEmpty(s)) { return(null); } s = RemoveFormatting(s); List <Match> matches = new List <Match>(); string[] matchArr = s.Split(MATCH_SEPARATOR); foreach (string match in matchArr) { try { if (string.IsNullOrEmpty(match)) { continue; } string[] properties = match.Split(PROPERTY_SEPARATOR); Match m = new Match(client); int lastMatchOutcome = -1; for (int i = 0; i < properties.Length; i++) { if (string.IsNullOrEmpty(properties[i])) { Logger.OutputError($"Empty property at value {i}"); continue; } if (i == 0) { m.MatchId = int.Parse(properties[i]); } else if (i == 1) { m.AccountId = properties[i]; } else if (i == 2) { m.MatchMode = (MatchMode)IntToEnum <MatchMode>(int.Parse(properties[i]), MatchMode.Matchmaking); } else if (i == 3) { m.Duration = TimeSpan.Parse(properties[i]); } else if (i == 4) { m.ServerVersion = int.Parse(properties[i]); } else if (i == 5) { ///Store winning team outcome to set later lastMatchOutcome = int.Parse(properties[i]); } else if (i == 6) { m.Turns = int.Parse(properties[i]); } else if (i == 7) { m.StartTime = DateTime.Parse(properties[i]); } else if (i == 8) { m.ClusterId = int.Parse(properties[i]); } else if (i == 9) { m.Team = (Teams)IntToEnum <Teams>(int.Parse(properties[i]), Teams.Radiant); } else if (i == 10) { m.Flags = (Flags)IntToEnum <Flags>(int.Parse(properties[i]), Flags.None); } else if (i == 11) { m.Tower1 = int.Parse(properties[i]); } else if (i == 12) { m.Tower2 = int.Parse(properties[i]); } else if (i == 13) { m.Tower3 = int.Parse(properties[i]); } else if (i == 14) { m.Ancient = int.Parse(properties[i]); } else if (i == 15) { m.GameClock = int.Parse(properties[i]); } else if (i == 16) { m.Hero1 = properties[i]; } else if (i == 17) { m.Hero2 = properties[i]; } else if (i == 18) { m.Hero3 = properties[i]; } else if (i == 19) { m.Hero4 = properties[i]; } else if (i == 20) { m.Hero5 = properties[i]; } else if (i == 21) { m.GauntletType = (GauntletType)IntToEnum <GauntletType>(int.Parse(properties[i]), GauntletType.None); } else if (i == 22) { //NOTE: Deck code currently isn't the correct deck code the player used in game //More info in the ReadMe.md m.DeckCode = properties[i]; } else { throw new NotImplementedException($"Unknown property - '{properties[i]}'"); } } ///Set win outcome by seeing if the player's team matches the outcome team object value = IntToEnum <Teams>(lastMatchOutcome, -1); if (value is int) { ///The value doesn't exist in Teams - Meaning outcome isn't from a Team winning switch (lastMatchOutcome) { case 8: m.Flags = Flags.Abandoned; break; default: Logger.OutputError($"Unknown Match outcome '{lastMatchOutcome}'"); break; } } else { ///If Outcome is Radiant or Dire, determine win or loss m.MatchOutcome = (Teams)lastMatchOutcome == m.Team ? Outcome.Victory : Outcome.Loss; } ///Only add one instance of the game Id to the list. ///Currently an issue with duplicate games in the history (Check ReadMe.md) if (!matches.Exists(x => x.MatchId == m.MatchId)) { matches.Add(m); } } catch (Exception e) { Logger.OutputError($"Unable to decode pasted content - '{e.ToString()}'"); return(null); } } return(matches); }
public BankAccountService(ArtifactClient artifactClient, ILogger <BankAccountService> logger) { _artifactClient = artifactClient; _logger = logger; }
public ContractService(ArtifactClient artifactClient, SigningClient signingClient) { _artifactClient = artifactClient; _signingClient = signingClient; }