-
Notifications
You must be signed in to change notification settings - Fork 12
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
INaidanov
authored and
INaidanov
committed
Mar 11, 2020
1 parent
9957cda
commit af380da
Showing
6 changed files
with
253 additions
and
141 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/CompareUserTypeInQueryTest.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,37 @@ | ||
namespace NewPlatform.Flexberry.ORM.ODataService.Tests.CRUD.Read | ||
{ | ||
using System.Linq; | ||
using ICSSoft.STORMNET; | ||
using ICSSoft.STORMNET.Business.LINQProvider; | ||
using Xunit; | ||
|
||
/// <summary> | ||
/// Сравнение пользовательского типа в Query | ||
/// </summary> | ||
public class CompareUserTypeInQueryTest : BaseODataServiceIntegratedTest | ||
{ | ||
/// <summary> | ||
/// ok. | ||
/// </summary> | ||
[Fact] | ||
public void RunTest() | ||
{ | ||
ActODataService(args => | ||
{ | ||
var type = new TypeSavedAsString { Text = "hello world" }; | ||
Автор автор = new Автор { Имя = "Паша", CustomSerializedType = type }; | ||
Библиотека библиотека = new Библиотека { Адрес = "Магнитогорск" }; | ||
var журнал = new Журнал { Автор2 = автор, Библиотека2 = библиотека }; | ||
var объекты = new DataObject[] { автор, библиотека, журнал }; | ||
args.DataService.UpdateObjects(ref объекты); | ||
var жур = args.DataService.Query<Журнал>("Dжурнал") | ||
.Where(x => x.Автор2.CustomSerializedType != null) | ||
.FirstOrDefault(); | ||
Assert.NotNull(жур); | ||
Assert.Equal("hello world", жур.Автор2.CustomSerializedType.Text); | ||
}); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
namespace NewPlatform.Flexberry.ORM.ODataService.Tests | ||
{ | ||
using System; | ||
using ICSSoft.STORMNET; | ||
|
||
/// <summary> | ||
/// Пользовательский тип, сериализующийся в строку | ||
/// </summary> | ||
[StoreInstancesInType(typeof(ICSSoft.STORMNET.Business.SQLDataService), typeof(string))] | ||
[Serializable] | ||
public class TypeSavedAsString : IComparableType | ||
{ | ||
public string Text { get; set; } | ||
|
||
public static explicit operator string(TypeSavedAsString value) | ||
{ | ||
return string.Concat(value.Text, "|Serialized"); | ||
} | ||
|
||
public static explicit operator TypeSavedAsString(string value) | ||
{ | ||
return new TypeSavedAsString | ||
{ | ||
Text = value.Split('|')[0] | ||
}; | ||
} | ||
|
||
public static bool operator !=(TypeSavedAsString l, TypeSavedAsString r) | ||
{ | ||
return !(l == r); | ||
} | ||
|
||
public static bool operator ==(TypeSavedAsString l, TypeSavedAsString r) | ||
{ | ||
return ((string)l).Equals((string)r); | ||
} | ||
|
||
public int Compare(object x) | ||
{ | ||
var obj = (TypeSavedAsString)x; | ||
return this.Text == obj.Text ? 0 : 1; | ||
} | ||
} | ||
} |
Oops, something went wrong.