C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
Test_ExchangeRateTable.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3
4using AnalyzeRe;
10
11#if MSTEST
12using Microsoft.VisualStudio.TestTools.UnitTesting;
13#elif NUNIT
14using NUnit.Framework;
15using TestClass = NUnit.Framework.TestFixtureAttribute;
16using TestMethod = NUnit.Framework.TestAttribute;
17using TestCategory = NUnit.Framework.CategoryAttribute;
18#endif
19
21{
22 [TestClass]
27
28 [TestClass]
29 public sealed class TestSuite_ExchangeRateTable : BaseResourceWithDataTestSuite<ExchangeRateTable>
30 {
31 #region Set Up and Configuration
32 private const string TypeName = "ExchangeRateTable";
35
36 protected override string POSTData => Samples.CSV.Exchange_Rate_Table;
37 #endregion Set Up and Configuration
38
39 #region POST
40 #region base_currency
41 [TestMethod, TestCategory(TypeName)]
43 {
44 POST_Attribute_Null(e => e.base_currency);
45 }
46 [TestMethod, TestCategory(TypeName)]
48 {
49 POST_StringAttribute_Empty(e => e.base_currency);
50 }
51 #endregion base_currency
52
53 // TODO: Post with various valid and invalid exchange rate data.
54 #endregion POST
55
56 #region Test Data
57 [TestMethod, TestCategory(TypeName)]
59 {
60 GenericTest.POST_InvalidResourceWithData_Fails(TestResource,
61 "\"Currency\",\"Date\",\"Rate\"",
62 (CommitFailedException ex) => { });
63 }
64 #endregion Test Data
65
66 #region Test Currencies List
67 [TestMethod, TestCategory(TypeName)]
69 {
70 ExchangeRateTable posted = TestResource_Existing;
71 HashSet<string> uniqueCurrencies = posted.GetUniqueCurrencies();
72
73 Assert.IsNotNull(uniqueCurrencies,
74 "The exchange rate table has no unique currencies list.");
75 Assert.AreNotEqual(0, uniqueCurrencies.Count,
76 "The exchange rate table unique currencies list was empty.");
77 // Print the currencies list for debugging purposes.
78 Console.WriteLine("Exchange Rate Table unique currencies:\n" +
79 String.Join(",", uniqueCurrencies));
80
81 //We know that in the test resource we have 5 unique currencies: JPY, GBP, CHF, EUR, CAD.
82 //If the test source changes, we need to update this test.
83 Assert.AreEqual(5, uniqueCurrencies.Count);
84 Assert.IsTrue(new HashSet<string>{ "JPY", "GBP", "CHF", "EUR", "CAD" }.SetEquals(uniqueCurrencies));
85 }
86 #endregion Test Currencies List
87 }
88}
Tests for a stored resource collection which do not require an instance of that resource to be define...
Exposes the various sample CSV files as strings.
Definition Samples.CSV.cs:9
static string Exchange_Rate_Table
Exposes sample resource objects, with built-in methods for injecting dependencies.
Definition Samples.cs:14
IInjectableResource< ExchangeRateTable > ExchangeRateTable
override IResourceCollection< ExchangeRateTable > collection_source
override IInjectableResource< ExchangeRateTable > TestInjectableResource
Generic Unit test implementations that will test REST methods on arbitrary resources.
Describes a collection of resources which can be listed.
API methods / requests made available to the user.
static readonly ResourceCollection< ExchangeRateTable > ExchangeRateTables
The collection of ExchangeRateTables on the server.
A table containing exchange rate information.
Exception raised when the commit process fails.