-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from Countly/fix_segm_same_keys
fix: segmentation same key
- Loading branch information
Showing
7 changed files
with
149 additions
and
3 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
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
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,92 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using CountlySDK; | ||
using CountlySDK.Entities; | ||
using Xunit; | ||
using static CountlySDK.CountlyCommon.CountlyBase; | ||
|
||
namespace TestProject_common | ||
{ | ||
public class SegmentationTests : IDisposable | ||
{ | ||
/// <summary> | ||
/// Test setup | ||
/// </summary> | ||
public SegmentationTests() | ||
{ | ||
CountlyImpl.SetPCLStorageIfNeeded(); | ||
Countly.Halt(); | ||
TestHelper.CleanDataFiles(); | ||
Countly.Instance.deferUpload = true; | ||
} | ||
|
||
/// <summary> | ||
/// Test cleanup | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
Countly.Instance.HaltInternal().Wait(); | ||
} | ||
|
||
[Fact] | ||
/// <summary> | ||
/// It validates the invalid key values | ||
/// All values are accepted | ||
/// Only validated invalid keys | ||
/// </summary> | ||
public void InvalidKeyValues() | ||
{ | ||
Segmentation segmentation = new Segmentation(); | ||
|
||
segmentation.Add(null, null); | ||
Assert.Empty(segmentation.segmentation); | ||
|
||
segmentation.Add("", null); | ||
Assert.Empty(segmentation.segmentation); | ||
|
||
segmentation.Add(" ", null); | ||
Assert.Equal(" ", segmentation.segmentation[0].Key); | ||
Assert.Null(segmentation.segmentation[0].Value); | ||
} | ||
|
||
[Fact] | ||
/// <summary> | ||
/// It validates valid values | ||
/// </summary> | ||
public void ValidKeyValues() | ||
{ | ||
Segmentation segmentation = new Segmentation(); | ||
|
||
segmentation.Add("1", "2"); | ||
Assert.Equal("1", segmentation.segmentation[0].Key); | ||
Assert.Equal("2", segmentation.segmentation[0].Value); | ||
|
||
segmentation.Add("3", "4"); | ||
Assert.Equal("3", segmentation.segmentation[1].Key); | ||
Assert.Equal("4", segmentation.segmentation[1].Value); | ||
Assert.Equal(2, segmentation.segmentation.Count); | ||
|
||
} | ||
|
||
[Fact] | ||
/// <summary> | ||
/// It validates valid values with same keys, | ||
/// this test shows no same keys accepted | ||
/// </summary> | ||
public void ValidKeyValues_SameKeys() | ||
{ | ||
Segmentation segmentation = new Segmentation(); | ||
|
||
segmentation.Add("1", "2"); | ||
Assert.Equal("1", segmentation.segmentation[0].Key); | ||
Assert.Equal("2", segmentation.segmentation[0].Value); | ||
|
||
segmentation.Add("1", "4"); | ||
Assert.Equal("1", segmentation.segmentation[0].Key); | ||
Assert.Equal("4", segmentation.segmentation[0].Value); | ||
Assert.Single(segmentation.segmentation); | ||
|
||
} | ||
|
||
} | ||
} |
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
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
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
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