Skip to content

Commit 6b9b05c

Browse files
authored
Merge pull request #180 from Nfactor26/download-only-updated-fixture-tests-and-testdatasource
Test cases, fixtures and data sources : Download only if we don't have most recent copy and don't load if marked deleted
2 parents d90ec1a + 57d9c63 commit 6b9b05c

23 files changed

+128
-71
lines changed

src/Pixel.Automation.Core/Constants.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,7 @@ public static class Constants
9999
/// </summary>
100100
public static readonly string ApplicationsMeta = "Applications.meta";
101101

102-
/// <summary>
103-
/// Meta data file name for projects
104-
/// </summary>
105-
public static readonly string ProjectsMeta = "Projects.meta";
106-
107-
/// <summary>
108-
/// Meta data file name for project versions
109-
/// </summary>
110-
public static readonly string VersionsMeta = "Versions.meta";
102+
public static readonly string LastUpdatedFileName = "lastupdated";
103+
111104
}
112105
}

src/Pixel.Automation.Core/FileSystem/ProjectFileSystem.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ public IEnumerable<TestDataSource> GetTestDataSources()
9696
foreach (var dataSourceFile in dataSourceFiles)
9797
{
9898
var testDataSource = serializer.Deserialize<TestDataSource>(dataSourceFile);
99+
if(testDataSource.IsDeleted)
100+
{
101+
continue;
102+
}
99103
yield return testDataSource;
100104
}
101105
yield break;

src/Pixel.Automation.Core/TestData/TestCase.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Pixel.Automation.Core.Attributes;
22
using Pixel.Automation.Core.Enums;
33
using System;
4+
using System.Diagnostics.SymbolStore;
45
using System.Runtime.Serialization;
56
using System.Text.Json.Serialization;
67

@@ -81,6 +82,12 @@ public class TestCase : ICloneable
8182
[DataMember(IsRequired = true, Order = 110)]
8283
public TagCollection Tags { get; private set; } = new TagCollection();
8384

85+
/// <summary>
86+
/// Indicates if the TestCase is deleted. Deleted test cases are not loaded in explorer.
87+
/// </summary>
88+
[DataMember(IsRequired = false, Order = 1000)]
89+
public bool IsDeleted { get; set; }
90+
8491
/// <summary>
8592
/// Root entity for the test case
8693
/// </summary>

src/Pixel.Automation.Core/TestData/TestDataSource.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public class TestDataSource
4040
/// </summary>
4141
[DataMember(IsRequired = true, Order = 50)]
4242
public DataSourceConfiguration MetaData { get; set; }
43+
44+
45+
/// <summary>
46+
/// Indicates if the TestDataSource is deleted. Deleted data sources are not loaded in explorer.
47+
/// </summary>
48+
[DataMember(IsRequired = false, Order = 1000)]
49+
public bool IsDeleted { get; set; }
4350
}
4451

4552
/// <summary>

src/Pixel.Automation.Core/TestData/TestFixture.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ public class TestFixture
6666
[DataMember(IsRequired = true, Order = 90)]
6767
public TagCollection Tags { get; private set; } = new TagCollection();
6868

69+
/// <summary>
70+
/// Indicates if the fixture was deleted. Deleted fixtures are not loaded in explorer.
71+
/// </summary>
72+
[DataMember(IsRequired = false, Order = 1000)]
73+
public bool IsDeleted { get; set; }
74+
6975
/// <summary>
7076
/// Collection of tests belonging to a fixture
7177
/// </summary>

src/Pixel.Automation.TestExplorer.ViewModels/TestExplorerViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,20 @@ async Task LoadDataAsync()
118118
foreach (var testFixtureDirectory in Directory.GetDirectories(this.fileSystem.TestCaseRepository))
119119
{
120120
var testFixture = this.fileSystem.LoadFiles<TestFixture>(testFixtureDirectory).Single();
121+
if(testFixture.IsDeleted)
122+
{
123+
continue;
124+
}
121125
TestFixtureViewModel testFixtureVM = new TestFixtureViewModel(testFixture);
122126
this.TestFixtures.Add(testFixtureVM);
123127

124128
foreach (var testCaseDirectory in Directory.GetDirectories(Path.Combine(this.fileSystem.TestCaseRepository, testFixture.FixtureId)))
125129
{
126130
var testCase = this.fileSystem.LoadFiles<TestCase>(testCaseDirectory).Single();
131+
if(testCase.IsDeleted)
132+
{
133+
continue;
134+
}
127135
TestCaseViewModel testCaseVM = new TestCaseViewModel(testCase);
128136
testFixtureVM.Tests.Add(testCaseVM);
129137
}

src/Pixel.Persistence.Respository/Interfaces/ITestCaseRepository.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Pixel.Persistence.Core.Models;
2+
using System;
23
using System.Collections.Generic;
34
using System.Threading;
45
using System.Threading.Tasks;
@@ -8,13 +9,13 @@ namespace Pixel.Persistence.Respository.Interfaces;
89
public interface ITestCaseRepository
910
{
1011
/// <summary>
11-
/// Get all test cases for a given project version
12+
/// Get all test cases for a given project version which were modified after specified datetime
1213
/// </summary>
1314
/// <param name="projectId"></param>
1415
/// <param name="projectVersion"></param>
1516
/// <param name="cancellationToken"></param>
1617
/// <returns></returns>
17-
Task<IEnumerable<TestCase>> GetTestCasesAsync(string projectId, string projectVersion, CancellationToken cancellationToken);
18+
Task<IEnumerable<TestCase>> GetTestCasesAsync(string projectId, string projectVersion, DateTime laterThan, CancellationToken cancellationToken);
1819

1920
/// <summary>
2021
/// Get test cases by Id for a given version of project

src/Pixel.Persistence.Respository/Interfaces/ITestDataRepository.cs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Pixel.Persistence.Core.Models;
2+
using System;
23
using System.Collections.Generic;
34
using System.Threading;
45
using System.Threading.Tasks;
@@ -8,62 +9,63 @@ namespace Pixel.Persistence.Respository.Interfaces
89
public interface ITestDataRepository
910
{
1011
/// <summary>
11-
/// Add a TestDataSource to a given version of project
12+
/// Get TestDataSource by Id for a given version of project
1213
/// </summary>
13-
/// <param name="dataSource"></param>
14+
/// <param name="projectId"></param>
15+
/// <param name="projectVersion"></param>
16+
/// <param name="fixtureId"></param>
1417
/// <param name="cancellationToken"></param>
1518
/// <returns></returns>
16-
Task AddDataSourceAsync(string projectId, string projectVersion, TestDataSource dataSource, CancellationToken cancellationToken);
19+
Task<TestDataSource> FindByIdAsync(string projectId, string projectVersion, string fixtureId, CancellationToken cancellationToken);
1720

1821
/// <summary>
19-
/// Add multiple TestDataSources to a given version of project
22+
/// Get TestDataSource by name for a given version of project
2023
/// </summary>
2124
/// <param name="projectId"></param>
2225
/// <param name="projectVersion"></param>
23-
/// <param name="dataSources"></param>
26+
/// <param name="name"></param>
2427
/// <param name="cancellationToken"></param>
2528
/// <returns></returns>
26-
Task AddDataSourcesAsync(string projectId, string projectVersion, IEnumerable<TestDataSource> dataSources, CancellationToken cancellationToken);
29+
Task<TestDataSource> FindByNameAsync(string projectId, string projectVersion, string name, CancellationToken cancellationToken);
2730

2831
/// <summary>
29-
/// Delete an existing TestDataSource for a given version of project
32+
/// Get all the TestDataSources available for a given version of project that were modified since specified datetime
3033
/// </summary>
3134
/// <param name="projectId"></param>
3235
/// <param name="projectVersion"></param>
33-
/// <param name="dataSourceId"></param>
36+
/// <param name="laterThan"></param>
3437
/// <param name="cancellationToken"></param>
3538
/// <returns></returns>
36-
Task DeleteDataSourceAsync(string projectId, string projectVersion, string dataSourceId, CancellationToken cancellationToken);
37-
39+
Task<IEnumerable<TestDataSource>> GetDataSourcesAsync(string projectId, string projectVersion, DateTime laterThan, CancellationToken cancellationToken);
40+
3841
/// <summary>
39-
/// Get TestDataSource by Id for a given version of project
42+
/// Add a TestDataSource to a given version of project
4043
/// </summary>
41-
/// <param name="projectId"></param>
42-
/// <param name="projectVersion"></param>
43-
/// <param name="fixtureId"></param>
44+
/// <param name="dataSource"></param>
4445
/// <param name="cancellationToken"></param>
4546
/// <returns></returns>
46-
Task<TestDataSource> FindByIdAsync(string projectId, string projectVersion, string fixtureId, CancellationToken cancellationToken);
47-
47+
Task AddDataSourceAsync(string projectId, string projectVersion, TestDataSource dataSource, CancellationToken cancellationToken);
48+
4849
/// <summary>
49-
/// Get TestDataSource by name for a given version of project
50+
/// Add multiple TestDataSources to a given version of project
5051
/// </summary>
5152
/// <param name="projectId"></param>
5253
/// <param name="projectVersion"></param>
53-
/// <param name="name"></param>
54+
/// <param name="dataSources"></param>
5455
/// <param name="cancellationToken"></param>
5556
/// <returns></returns>
56-
Task<TestDataSource> FindByNameAsync(string projectId, string projectVersion, string name, CancellationToken cancellationToken);
57-
57+
Task AddDataSourcesAsync(string projectId, string projectVersion, IEnumerable<TestDataSource> dataSources, CancellationToken cancellationToken);
58+
5859
/// <summary>
59-
/// Get all the TestDataSources available for a given version of project
60+
/// Delete an existing TestDataSource for a given version of project
6061
/// </summary>
6162
/// <param name="projectId"></param>
6263
/// <param name="projectVersion"></param>
64+
/// <param name="dataSourceId"></param>
6365
/// <param name="cancellationToken"></param>
6466
/// <returns></returns>
65-
Task<IEnumerable<TestDataSource>> GetDataSourcesAsync(string projectId, string projectVersion, CancellationToken cancellationToken);
66-
67+
Task DeleteDataSourceAsync(string projectId, string projectVersion, string dataSourceId, CancellationToken cancellationToken);
68+
6769
/// <summary>
6870
/// Update a TestDataSource for a given version of project
6971
/// </summary>

src/Pixel.Persistence.Respository/Interfaces/ITestFixtureRepository.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ namespace Pixel.Persistence.Respository.Interfaces;
99
public interface ITestFixtureRepository
1010
{
1111
/// <summary>
12-
/// Get all test fixtures for a given project version
12+
/// Get all test fixtures for a given project version which have been modified since specified datetime
1313
/// </summary>
1414
/// <param name="projectId">Identifier of the automation project</param>
1515
/// <param name="projectVersion">Version of the automation project</param>
1616
/// <returns></returns>
17-
Task<IEnumerable<TestFixture>> GetFixturesAsync(string projectId, string projectVersion, CancellationToken cancellationToken);
17+
Task<IEnumerable<TestFixture>> GetFixturesAsync(string projectId, string projectVersion, DateTime laterThan, CancellationToken cancellationToken);
18+
1819

1920
/// <summary>
2021
/// Get a test fixture given it's Id

src/Pixel.Persistence.Respository/ProjectsRepository.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,23 @@ public async Task AddProjectVersionAsync(string projectId, ProjectVersion newVer
105105
projectReference.Id = ObjectId.Empty;
106106
await this.referencesRepository.AddProjectReferences(projectId, newVersion.ToString(), projectReference);
107107

108-
var fixtures = await this.fixturesRepository.GetFixturesAsync(projectId, cloneFrom.ToString(), cancellationToken);
108+
109+
DateTime laterThan = DateTime.MinValue.ToUniversalTime();
110+
var fixtures = await this.fixturesRepository.GetFixturesAsync(projectId, cloneFrom.ToString(), laterThan, cancellationToken);
109111
foreach(var fixture in fixtures)
110112
{
111113
fixture.Id = ObjectId.Empty;
112114
}
113115
await this.fixturesRepository.AddFixturesAsync(projectId, newVersion.ToString(), fixtures, cancellationToken);
114116

115-
var tests = await this.testCaseRepository.GetTestCasesAsync(projectId, cloneFrom.ToString(), cancellationToken);
117+
var tests = await this.testCaseRepository.GetTestCasesAsync(projectId, cloneFrom.ToString(), laterThan, cancellationToken);
116118
foreach(var test in tests)
117119
{
118120
test.Id = ObjectId.Empty;
119121
}
120122
await this.testCaseRepository.AddTestCasesAsync(projectId, newVersion.ToString(), tests, cancellationToken);
121123

122-
var dataSources = await this.testDataRepository.GetDataSourcesAsync(projectId, cloneFrom.ToString(), cancellationToken);
124+
var dataSources = await this.testDataRepository.GetDataSourcesAsync(projectId, cloneFrom.ToString(), laterThan, cancellationToken);
123125
foreach(var dataSource in dataSources)
124126
{
125127
dataSource.Id = ObjectId.Empty;

0 commit comments

Comments
 (0)