-
Notifications
You must be signed in to change notification settings - Fork 3
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
52 changed files
with
1,805 additions
and
523 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Untech.SharePoint.Client.Test/Converters/BuiltIn/ContentTypeIdFieldConverterTest.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,16 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Untech.SharePoint.Client.Converters.BuiltIn; | ||
using Untech.SharePoint.Common.Converters; | ||
using Untech.SharePoint.Common.Test.Converters; | ||
|
||
namespace Untech.SharePoint.Client.Test.Converters.BuiltIn | ||
{ | ||
[TestClass] | ||
public class ContentTypeIdFieldConverterTest : BaseConverterTest | ||
{ | ||
protected override IFieldConverter GetConverter() | ||
{ | ||
return new ContentTypeIdConverter(); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Untech.SharePoint.Client.Test/Converters/BuiltIn/LookupMultiFieldConverterTest.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,34 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Untech.SharePoint.Client.Converters.BuiltIn; | ||
using Untech.SharePoint.Common.Converters; | ||
using Untech.SharePoint.Common.Models; | ||
using Untech.SharePoint.Common.Test.Converters; | ||
|
||
namespace Untech.SharePoint.Client.Test.Converters.BuiltIn | ||
{ | ||
[TestClass] | ||
public class LookupMultiFieldConverterTest : BaseConverterTest | ||
{ | ||
[TestMethod] | ||
public void CanSupportArray() | ||
{ | ||
Given<ObjectReference[]>(); | ||
} | ||
|
||
[TestMethod] | ||
public void CanSupportTypesAssignableFromList() | ||
{ | ||
Given<IEnumerable<ObjectReference>>(); | ||
Given<ICollection<ObjectReference>>(); | ||
Given<IReadOnlyCollection<ObjectReference>>(); | ||
Given<IList<ObjectReference>>(); | ||
Given<List<ObjectReference>>(); | ||
} | ||
|
||
protected override IFieldConverter GetConverter() | ||
{ | ||
return new LookupMultiFieldConverter(); | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
Untech.SharePoint.Client.Test/Converters/BuiltIn/UrlFieldConverterTest.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,77 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.SharePoint.Client; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Untech.SharePoint.Client.Converters.BuiltIn; | ||
using Untech.SharePoint.Common.Converters; | ||
using Untech.SharePoint.Common.Models; | ||
using Untech.SharePoint.Common.Test.Converters; | ||
|
||
namespace Untech.SharePoint.Client.Test.Converters.BuiltIn | ||
{ | ||
[TestClass] | ||
public class UrlFieldConverterTest : BaseConverterTest | ||
{ | ||
[TestMethod] | ||
public void CanConvertString() | ||
{ | ||
Given<string>() | ||
.CanConvertFromSp(null, null) | ||
.CanConvertFromSp(new FieldUrlValue {Url = "http://google.com", Description = "Google It!"}, "http://google.com") | ||
.CanConvertToSp(null, null) | ||
.CanConvertToSp("http://google.com", new FieldUrlValue {Url = "http://google.com"}, new FieldUrlValueComparer()) | ||
.CanConvertToCaml(null, "") | ||
.CanConvertToCaml("http://google.com", "http://google.com"); | ||
} | ||
|
||
[TestMethod] | ||
public void CanConvertUrlInfo() | ||
{ | ||
Given<UrlInfo>() | ||
.CanConvertFromSp(null, null) | ||
.CanConvertFromSp(new FieldUrlValue { Url = "http://google.com", Description = "Google It!" }, new UrlInfo{ Url = "http://google.com", Description = "Google It!" }, new UrlInfoComparer()) | ||
.CanConvertToSp(null, null) | ||
.CanConvertToSp(new UrlInfo { Url = "http://google.com", Description = "Google It!" }, new FieldUrlValue { Url = "http://google.com", Description = "Google It!" }, new FieldUrlValueComparer()) | ||
.CanConvertToCaml(null, "") | ||
.CanConvertToCaml(new UrlInfo { Url = "http://google.com", Description = "Google It!" }, "http://google.com;#Google It!"); | ||
} | ||
|
||
protected override IFieldConverter GetConverter() | ||
{ | ||
return new UrlFieldConverter(); | ||
} | ||
|
||
public class FieldUrlValueComparer : EqualityComparer<FieldUrlValue> | ||
{ | ||
public override bool Equals(FieldUrlValue x, FieldUrlValue y) | ||
{ | ||
return x.Url == y.Url && x.Description == y.Description; | ||
|
||
} | ||
|
||
public override int GetHashCode(FieldUrlValue obj) | ||
{ | ||
if (obj == null) return 0; | ||
var hash1 = (obj.Url ?? "").GetHashCode(); | ||
var hash2 = (obj.Description ?? "").GetHashCode(); | ||
return hash1 ^ hash2; | ||
} | ||
} | ||
|
||
public class UrlInfoComparer : EqualityComparer<UrlInfo> | ||
{ | ||
public override bool Equals(UrlInfo x, UrlInfo y) | ||
{ | ||
return x.Url == y.Url && x.Description == y.Description; | ||
|
||
} | ||
|
||
public override int GetHashCode(UrlInfo obj) | ||
{ | ||
if (obj == null) return 0; | ||
var hash1 = (obj.Url ?? "").GetHashCode(); | ||
var hash2 = (obj.Description ?? "").GetHashCode(); | ||
return hash1 ^ hash2; | ||
} | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Untech.SharePoint.Client.Test/Converters/BuiltIn/UserMultiFieldConverterTest.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,34 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Untech.SharePoint.Client.Converters.BuiltIn; | ||
using Untech.SharePoint.Common.Converters; | ||
using Untech.SharePoint.Common.Models; | ||
using Untech.SharePoint.Common.Test.Converters; | ||
|
||
namespace Untech.SharePoint.Client.Test.Converters.BuiltIn | ||
{ | ||
[TestClass] | ||
public class UserMultiFieldConverterTest : BaseConverterTest | ||
{ | ||
[TestMethod] | ||
public void CanSupportArray() | ||
{ | ||
Given<UserInfo[]>(); | ||
} | ||
|
||
[TestMethod] | ||
public void CanSupportTypesAssignableFromList() | ||
{ | ||
Given<IEnumerable<UserInfo>>(); | ||
Given<ICollection<UserInfo>>(); | ||
Given<IReadOnlyCollection<UserInfo>>(); | ||
Given<IList<UserInfo>>(); | ||
Given<List<UserInfo>>(); | ||
} | ||
|
||
protected override IFieldConverter GetConverter() | ||
{ | ||
return new UserMultiFieldConverter(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.