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

Add test on nulling master and delete #231

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,52 @@ public void AggregatorWithDetailsLoadedDeleteTest()
}
}

/// <summary>
/// Проверка механизма зануления и удаления мастера у класса.
/// </summary>
[Fact]
public void DeleteAndNullingLinkToSelfTest()
{
foreach (IDataService dataService in DataServices)
{
// TODO: Fix OracleDataService error.
if (dataService is OracleDataService)
{
continue;
}

string[] медведьPropertiesNames =
{
Information.ExtractPropertyPath<Медведь>(x => x.__PrimaryKey),
Information.ExtractPropertyPath<Медведь>(x => x.ЦветГлаз),
};
var медведьDynamicView = new View(new ViewAttribute("медведьDynamicView", медведьPropertiesNames), typeof(Медведь));

var testName = "Test";
var медведь1 = new Медведь();
var медведь2 = new Медведь() { Мама = медведь1, ЦветГлаз = testName };

var objs = new DataObject[] { медведь1, медведь2 };
dataService.UpdateObjects(ref objs);

// Act.
медведь2.Мама = null;
медведь1.SetStatus(ObjectStatus.Deleted);

var objsUpdate = new DataObject[] { медведь2, медведь1 };
dataService.UpdateObjects(ref objsUpdate);

// Assert.
LoadingCustomizationStruct lcs = LoadingCustomizationStruct.GetSimpleStruct(typeof(Медведь), медведьDynamicView);
var медведиObj = dataService.LoadObjects(lcs);
var медведи = медведиObj.Cast<Медведь>().ToList();

Assert.Single(медведиObj);
Assert.Equal(testName, медведи[0].ЦветГлаз);
Assert.Null(медведи[0].Мама);
}
}

/// <summary>
/// Тесты на формирование графа зависимостей методом <see cref="SQLDataService.GetDependencies"/>.
/// </summary>
Expand Down