-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #369 from jburditt/fork
VS-6873 update readme
- Loading branch information
Showing
28 changed files
with
2,315 additions
and
34 deletions.
There are no files selected for viewing
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,73 @@ | ||
{ | ||
"info": { | ||
"_postman_id": "a1cf9a99-8a52-4deb-998a-e3b4e990bf41", | ||
"name": "COAST", | ||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", | ||
"_exporter_id": "730057" | ||
}, | ||
"item": [ | ||
{ | ||
"name": "VSD", | ||
"item": [ | ||
{ | ||
"name": "Payment/send POST", | ||
"request": { | ||
"method": "POST", | ||
"header": [], | ||
"url": { | ||
"raw": "https://coast-restitution-dev.silver.devops.bcgov/api/Payment/send", | ||
"host": [ | ||
"{{server}}" | ||
], | ||
"path": [ | ||
"Payment", | ||
"send" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "PaymentSchedule/schedule-cvap POST", | ||
"request": { | ||
"method": "POST", | ||
"header": [], | ||
"url": { | ||
"raw": "https://coast-restitution-dev.silver.devops.bcgov/api/PaymentSchedule/schedule-cvap", | ||
"host": [ | ||
"{{server}}" | ||
], | ||
"path": [ | ||
"PaymentSchedule", | ||
"schedule-cvap" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
} | ||
] | ||
} | ||
], | ||
"event": [ | ||
{ | ||
"listen": "prerequest", | ||
"script": { | ||
"type": "text/javascript", | ||
"packages": {}, | ||
"exec": [ | ||
"" | ||
] | ||
} | ||
}, | ||
{ | ||
"listen": "test", | ||
"script": { | ||
"type": "text/javascript", | ||
"packages": {}, | ||
"exec": [ | ||
"" | ||
] | ||
} | ||
} | ||
] | ||
} |
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,39 @@ | ||
using Microsoft.Xrm.Sdk; | ||
|
||
namespace Database.Model; | ||
|
||
public partial class DatabaseContext | ||
{ | ||
private bool isInTransaction; | ||
|
||
public new SaveChangesResultCollection SaveChanges() | ||
{ | ||
if (!isInTransaction) | ||
{ | ||
return base.SaveChanges(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public TransactionContext BeginTransaction() | ||
{ | ||
if (isInTransaction) throw new InvalidOperationException("Already in a transaction"); | ||
isInTransaction = true; | ||
return new TransactionContext(this); | ||
} | ||
|
||
public void CommitTransaction() | ||
{ | ||
if (isInTransaction) | ||
{ | ||
base.SaveChanges(); | ||
isInTransaction = false; | ||
} | ||
} | ||
} | ||
|
||
public class TransactionContext(DatabaseContext context) | ||
{ | ||
public void Commit() => context.CommitTransaction(); | ||
} |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
namespace Manager; | ||
|
||
public class ScheduleGHandlers(IScheduleGRepository repository) //: | ||
//QueryBaseHandlers<IScheduleGRepository, ScheduleG, ScheduleGQuery>(repository), | ||
//IRequestHandler<ScheduleGQuery, ScheduleGResult>, | ||
//IRequestHandler<InsertCommand<ScheduleG>, Guid> | ||
public class ScheduleGHandlers(IScheduleGRepository repository) : | ||
QueryBaseHandlers<IScheduleGRepository, ScheduleG, ScheduleGQuery>(repository), | ||
IRequestHandler<ScheduleGQuery, IEnumerable<ScheduleG>>, | ||
IRequestHandler<InsertCommand<ScheduleG>, Guid> | ||
{ | ||
|
||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace Resources; | ||
|
||
public interface IScheduleGRepository : IBaseRepository<ScheduleG>, IQueryRepository<ScheduleGQuery, ScheduleGResult> | ||
public interface IScheduleGRepository : IBaseRepository<ScheduleG>, IQueryRepository<ScheduleGQuery, ScheduleG> | ||
{ | ||
|
||
} |
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,5 @@ | ||
public class FakeDto : IDto | ||
{ | ||
public Guid Id { get; set; } | ||
public StateCode StateCode { get; set; } | ||
} |
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,8 @@ | ||
public class FakeHandlers(IFakeRepository repository) : BaseHandlers<IFakeRepository, FakeDto>(repository), | ||
IRequestHandler<InsertCommand<FakeDto>, Guid>, | ||
IRequestHandler<UpsertCommand<FakeDto>, Guid>, | ||
IRequestHandler<DeleteCommand<FakeDto>, bool>, | ||
IRequestHandler<TryDeleteCommand<FakeDto>, bool>, | ||
IRequestHandler<TryDeleteByDtoCommand<FakeDto>, bool> | ||
{ | ||
} |
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,56 @@ | ||
using AutoMapper; | ||
using System.Linq.Expressions; | ||
|
||
namespace Resources; | ||
|
||
public class FakeRepository : IFakeRepository | ||
{ | ||
protected readonly DatabaseContext _databaseContext; | ||
protected readonly IMapper _mapper; | ||
|
||
public FakeRepository(DatabaseContext databaseContext, IMapper mapper) | ||
{ | ||
_databaseContext = databaseContext; | ||
_mapper = mapper; | ||
} | ||
|
||
public virtual Guid Insert(FakeDto dto) | ||
{ | ||
return new Guid(); | ||
} | ||
|
||
public virtual Guid Upsert(FakeDto dto) | ||
{ | ||
return new Guid(); | ||
} | ||
|
||
public IEnumerable<FakeDto> Where(Expression<Func<FakeDto, bool>> predicates) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool Update(FakeDto dto) | ||
{ | ||
return true; | ||
} | ||
|
||
public virtual bool TryDelete(Guid id) | ||
{ | ||
return true; | ||
} | ||
|
||
public virtual bool TryDelete(FakeDto dto, bool isRecursive = false) | ||
{ | ||
return true; | ||
} | ||
|
||
public virtual bool TryDeleteRange(IEnumerable<FakeDto> invoices, bool isRecursive = false) | ||
{ | ||
return true; | ||
} | ||
|
||
public virtual bool Delete(Guid id) | ||
{ | ||
return true; | ||
} | ||
} |
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,3 @@ | ||
public interface IFakeRepository : IBaseRepository<FakeDto> | ||
{ | ||
} |
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,105 @@ | ||
public class ContractRepositoryTests(IContractRepository repository) | ||
{ | ||
// WARNING!!! these are not reliable tests, they will fail, these were shortcuts I used for building a POC, these tests will need to be adjusted in order to be idempotent | ||
|
||
[Fact] | ||
public void Insert() | ||
{ | ||
// Arrange | ||
var contract = FakeData.Contracts[0]; | ||
|
||
// Act | ||
var id = repository.Insert(contract); | ||
|
||
// Assert | ||
Assert.True(id != Guid.Empty); | ||
} | ||
|
||
[Fact] | ||
public void Upsert() | ||
{ | ||
// Arrange | ||
var contract = FakeData.Contracts[0]; | ||
|
||
// Act | ||
var id = repository.Upsert(contract); | ||
|
||
// Assert | ||
Assert.True(id != Guid.Empty); | ||
} | ||
|
||
[Fact] | ||
public void Query() | ||
{ | ||
// Arrange | ||
var command = new ContractQuery(); | ||
|
||
// Act | ||
var result = repository.Query(command); | ||
|
||
// Assert | ||
Assert.True(result.Count() > 0); | ||
} | ||
|
||
[Fact] | ||
public void Delete() | ||
{ | ||
// Arrange | ||
var id = new Guid(""); | ||
|
||
// Act | ||
var result = repository.TryDelete(id); | ||
|
||
// Assert | ||
Assert.True(result); | ||
} | ||
|
||
// FINDINGS | ||
// Cloning using the vsd_CloneContract Action does not duplicate all fields like Dynamics scheduled job does | ||
// Cannot save vsd_contract entity with "DulyExecuted" status code | ||
// Scheduled Job worked the first time and then stopped working, no clone was found and vsd_ClonedContractId was null | ||
[Fact] | ||
public void Clone() | ||
{ | ||
// Arrange | ||
var command = new ContractQuery(); | ||
command.StateCode = StateCode.Active; | ||
command.StatusCode = ContractStatusCode.DulyExecuted; | ||
command.CpuCloneFlag = true; | ||
|
||
// Act | ||
var result = repository.Query(command); | ||
Guid? id = null; | ||
foreach (var contract in result) | ||
{ | ||
if (!repository.IsCloned(contract.Id)) | ||
{ | ||
id = repository.Clone(contract.Id); | ||
} | ||
} | ||
|
||
// Assert | ||
Assert.NotNull(id); | ||
} | ||
|
||
[Fact] | ||
public void Delete_Clones() | ||
{ | ||
var query = new ContractQuery(); | ||
query.StateCode = StateCode.Active; | ||
query.StatusCode = ContractStatusCode.DulyExecuted; | ||
query.CpuCloneFlag = true; | ||
var result = repository.Query(query); | ||
|
||
List<Guid> ids = new List<Guid>(); | ||
foreach (var contract in result) | ||
{ | ||
// if cloned | ||
if (repository.IsCloned(contract.Id)) | ||
{ | ||
// delete the clone | ||
repository.DeleteClone(contract.Id); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.