-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
144 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
RaptorSheets.Stock.Tests/Helpers/StockSheetHelpersTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using Google.Apis.Sheets.v4.Data; | ||
using Moq; | ||
using RaptorSheets.Core.Models.Google; | ||
using RaptorSheets.Stock.Enums; | ||
using RaptorSheets.Stock.Helpers; | ||
using RaptorSheets.Stock.Entities; | ||
using RaptorSheets.Stock.Constants; | ||
using Xunit; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace RaptorSheets.Tests.Helpers | ||
{ | ||
public class StockSheetHelpersTests | ||
{ | ||
[Fact] | ||
public void GetSheets_ShouldReturnAllSheets() | ||
{ | ||
// Act | ||
var result = StockSheetHelpers.GetSheets(); | ||
|
||
// Assert | ||
Assert.Contains(result, sheet => sheet.Name == "Accounts"); | ||
Assert.Contains(result, sheet => sheet.Name == "Stocks"); | ||
Assert.Contains(result, sheet => sheet.Name == "Tickers"); | ||
} | ||
|
||
[Fact] | ||
public void GetMissingSheets_ShouldReturnMissingSheets() | ||
{ | ||
// Arrange | ||
var spreadsheet = new Spreadsheet | ||
{ | ||
Sheets = new List<Sheet> | ||
{ | ||
new Sheet { Properties = new SheetProperties { Title = "Accounts" } } | ||
} | ||
}; | ||
|
||
// Act | ||
var result = StockSheetHelpers.GetMissingSheets(spreadsheet); | ||
|
||
// Assert | ||
Assert.Contains(result, sheet => sheet.Name == "Stocks"); | ||
Assert.Contains(result, sheet => sheet.Name == "Tickers"); | ||
} | ||
|
||
[Fact] | ||
public void GetDataValidation_ShouldReturnBooleanValidation() | ||
{ | ||
// Act | ||
var result = StockSheetHelpers.GetDataValidation(ValidationEnum.BOOLEAN); | ||
|
||
// Assert | ||
Assert.Equal("BOOLEAN", result.Condition.Type); | ||
} | ||
|
||
[Fact] | ||
public void GetDataValidation_ShouldReturnRangeValidation() | ||
{ | ||
// Act | ||
var result = StockSheetHelpers.GetDataValidation(ValidationEnum.RANGE_ACCOUNT); | ||
|
||
// Assert | ||
Assert.Equal("ONE_OF_RANGE", result.Condition.Type); | ||
Assert.Contains(result.Condition.Values, v => v.UserEnteredValue == "=Accounts!A2:A"); | ||
} | ||
|
||
[Fact] | ||
public void MapData_ShouldReturnSheetEntity() | ||
{ | ||
// Arrange | ||
var response = new BatchGetValuesByDataFilterResponse | ||
{ | ||
ValueRanges = new List<MatchedValueRange> | ||
{ | ||
new MatchedValueRange | ||
{ | ||
DataFilters = new List<DataFilter> { new DataFilter { A1Range = "Accounts" } }, | ||
ValueRange = new ValueRange { Values = new List<IList<object>> { new List<object> { "Header1", "Header2" } } } | ||
} | ||
} | ||
}; | ||
|
||
// Act | ||
var result = StockSheetHelpers.MapData(response); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
Assert.NotNull(result.Accounts); | ||
} | ||
} | ||
} |