Skip to content
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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

Added Assertions #238

wants to merge 6 commits into from

Conversation

naanaowusu
Copy link

There are several assertions i added

@Anisimova2020 Anisimova2020 self-requested a review March 7, 2023 06:08
@@ -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 \
Copy link
Contributor

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
Copy link
Contributor

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;" />
Copy link
Contributor

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;
Copy link
Contributor

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?

@@ -114,6 +114,11 @@ public void GenerateSQLSelectSingleJoinTest()
ds.ExecuteNonQuery(query1);
ds.ExecuteNonQuery(query2);
ds.ExecuteNonQuery(query3);

Assert.DoesNotContain(query0, "LEFT JOIN");
Copy link
Contributor

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);
Copy link
Contributor

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();
Copy link
Contributor

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.

@@ -4,7 +4,7 @@ services:
postgres:
image: flexberry/alt.p8-postgresql-postgis
ports:
- 5432:5432
- 5433:5432
Copy link
Contributor

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.

@@ -0,0 +1,12 @@
version: '3.2'
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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)

@@ -2,7 +2,6 @@
{
using System;
using System.Diagnostics;

Copy link
Contributor

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");
Copy link
Contributor

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)));
Copy link
Contributor

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)));

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(
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same.

@sonarcloud
Copy link

sonarcloud bot commented Apr 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants