-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Assertions #238
base: develop
Are you sure you want to change the base?
Added Assertions #238
Conversation
@@ -4,7 +4,7 @@ environmentFile=../environment_test.sh | |||
docker run -d \ | |||
--name=postgres \ | |||
-e POSTGRES_shared_buffers=${DB_POSTGRES_shared_buffers} \ | |||
-p 5432:5432 \ | |||
-p 5433:5432 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be commited.
@@ -4,7 +4,7 @@ services: | |||
postgres: | |||
image: flexberry/alt.p8-postgresql | |||
ports: | |||
- 5432:5432 | |||
- 5433:5432 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be commited.
@@ -6,7 +6,7 @@ | |||
</configSections> | |||
<connectionStrings> | |||
<!-- Please set up your own database connection strings before you run integrated tests. --> | |||
<add name="ConnectionStringPostgres" connectionString="" /> | |||
<add name="ConnectionStringPostgres" connectionString="SERVER=localhost;User ID=postgres;Password=p@ssw0rd;Port=5433;" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be commited.
@@ -2,7 +2,7 @@ | |||
{ | |||
using System; | |||
using System.Collections.Generic; | |||
|
|||
using System.Diagnostics; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this using added here for?
...Flexberry.ORM.IntegratedTests/ICSSoft.STORMNET.Business.LINQProvider/LinqODataServiceTest.cs
Show resolved
Hide resolved
@@ -114,6 +114,11 @@ public void GenerateSQLSelectSingleJoinTest() | |||
ds.ExecuteNonQuery(query1); | |||
ds.ExecuteNonQuery(query2); | |||
ds.ExecuteNonQuery(query3); | |||
|
|||
Assert.DoesNotContain(query0, "LEFT JOIN"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для чистоты эксперимента нужно делать query0.ToUpper() и аналогично ниже.
Assert.Equal("A", ((OrderedCls)entrysl.Value).Name); | ||
} | ||
|
||
// Assert.Equal("A", ((OrderedCls)((DictionaryEntry)myValueList[0]).Value).Name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't commit commented code.
@@ -73,6 +73,32 @@ public void TestMethod1() | |||
{ | |||
Console.WriteLine(((OrderedCls)((DictionaryEntry)cls).Value).Name); | |||
} | |||
|
|||
IList myOrderList = sl.GetKeyList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As i remember we planned to add asserts on LST, BSS, S1 to this method.
docker-compose.yml
Outdated
@@ -4,7 +4,7 @@ services: | |||
postgres: | |||
image: flexberry/alt.p8-postgresql-postgis | |||
ports: | |||
- 5432:5432 | |||
- 5433:5432 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not commit this.
docker-compose.yml.bak
Outdated
@@ -0,0 +1,12 @@ | |||
version: '3.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be commited to server.
var ds = (SQLDataService)dataService; | ||
ds.UpdateObjects(ref objs); | ||
|
||
var v = new View(new ViewAttribute("AllProps", new string[] { "*" }), typeof(Кошка)); | ||
View v = new View(new ViewAttribute("AllProps", new string[] { "*" }), typeof(Кошка)); | ||
var ob = ds.LoadObjects(v); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var стоит заменить на реальный тип.
Проверить, что "ob" не NULL и проверить количество элементов (через Assert).
View plantView = Plant2.Views.Plant2E; | ||
|
||
IQueryable<Plant2> plant2s = ds.Query<Plant2>(plantView) | ||
.Where(x => x.__PrimaryKey == cls1.__PrimaryKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В конце этой конструкции нужно добавить ToList(); Тогда plant2s будет типа List.
После этого нужно сделать не только
Assert.NotNull(plant2s);, но и Assert.Equal(..., plant2s.Length)
...Flexberry.ORM.IntegratedTests/ICSSoft.STORMNET.Business.LINQProvider/LinqODataServiceTest.cs
Outdated
Show resolved
Hide resolved
@@ -2,7 +2,6 @@ | |||
{ | |||
using System; | |||
using System.Diagnostics; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь эта строка нужная.
Using, которые начинаются с System, отделяются от остальных пустой строчкой.
@@ -114,6 +114,11 @@ public void GenerateSQLSelectSingleJoinTest() | |||
ds.ExecuteNonQuery(query1); | |||
ds.ExecuteNonQuery(query2); | |||
ds.ExecuteNonQuery(query3); | |||
|
|||
Assert.DoesNotContain(query0.ToUpper(), "LEFT JOIN"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DoesNotContain(expectedSubString, actualString) (https://metanit.com/sharp/aspnet5/22.3.php)
Это значит, что первый параметр - это подстрока, а второй - строка, где мы ищем эту подстроку. Соответственно, нужно
Assert.DoesNotContain("LEFT JOIN", query0.ToUpper())
@@ -19,6 +19,7 @@ public void GetUsableTypeNameTest() | |||
str = Nullable.GetUnderlyingType(tBool).FullName; | |||
Console.WriteLine(str); | |||
Console.WriteLine(Nullable.GetUnderlyingType(typeof(int)) == null ? "null" : Nullable.GetUnderlyingType(typeof(int)).FullName); | |||
Assert.Null(Nullable.GetUnderlyingType(typeof(int))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше "Nullable.GetUnderlyingType(typeof(int))" в отдельную переменную, а потом использовать в строчках:
Console.WriteLine(Nullable.GetUnderlyingType(typeof(int)) == null ? "null" : Nullable.GetUnderlyingType(typeof(int)).FullName);
Assert.Null(Nullable.GetUnderlyingType(typeof(int)));
...Flexberry.ORM.IntegratedTests/ICSSoft.STORMNET.Business.LINQProvider/LinqODataServiceTest.cs
Show resolved
Hide resolved
var ob = ds.LoadObjects(v); | ||
View v = new View(new ViewAttribute("AllProps", new string[] { "*" }), typeof(Кошка)); | ||
DataObject[] ob = ds.LoadObjects(v); | ||
Assert.NotNull(ob); | ||
|
||
var l = ds.Query<Медведь>(Медведь.Views.МедведьE).Where( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сразу замени var на реальный тип.
|
||
View plantView = Plant2.Views.Plant2E; | ||
|
||
IQueryable<Plant2> plant2s = ds.Query<Plant2>(plantView) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can not understand.
"IQueryable plant2s = ds.Query(plantView).Where(x => x.__PrimaryKey == cls1.__PrimaryKey);"
and
"Plant2 cl = new Plant2();
cl.SetExistObjectPrimaryKey(cls1.__PrimaryKey);
ds.LoadObject(plantView, cl);
Assert.NotNull(cl);"
make the same. What for is there two same checks? Only one should be.
|
||
View cabbageView = Cabbage2.Views.Cabbage2E; | ||
|
||
IQueryable<Cabbage2> cabbage2s = ds.Query<Cabbage2>(cabbageView) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same.
Kudos, SonarCloud Quality Gate passed! |
There are several assertions i added