Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

CloseQuoteRequest execution should actually change quote's state to Closed (3). #493

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -34,14 +34,11 @@ public OrganizationResponse Execute(OrganizationRequest request, XrmFakedContext
throw new Exception("Quote ID is not set on QuoteClose, but is required");
}

var update = new Entity
var update = new Entity("quote")
{
Id = quoteId.Id,
LogicalName = "quote",
Attributes = new AttributeCollection
{
{ "statuscode", closeRequest.Status }
}
["statecode"] = new OptionSetValue(3),
["statuscode"] = closeRequest.Status
};

var service = ctx.GetOrganizationService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace FakeXrmEasy.Tests.FakeContextTests.CloseQuoteRequestTests
{
public class CloseQuoteRequestTests
{
private static readonly OptionSetValue StateDraft = new OptionSetValue(0);
private static readonly OptionSetValue StateClosed = new OptionSetValue(3);
private static readonly OptionSetValue StatusInProgress = new OptionSetValue(1);
private static readonly OptionSetValue StatusCanceled = new OptionSetValue(6);

[Fact]
public void When_can_execute_is_called_with_an_invalid_request_result_is_false()
{
Expand All @@ -24,14 +29,11 @@ public void Should_Change_Status_When_Closing()
var context = new XrmFakedContext();
var service = context.GetOrganizationService();

var quote = new Entity
var quote = new Entity("quote")
{
LogicalName = "quote",
Id = Guid.NewGuid(),
Attributes = new AttributeCollection
{
{"statuscode", new OptionSetValue(0)}
}
["statecode"] = StateDraft,
["statuscode"] = StatusInProgress
};

context.Initialize(new[]
Expand All @@ -43,21 +45,19 @@ public void Should_Change_Status_When_Closing()

var req = new CloseQuoteRequest
{
QuoteClose = new Entity
QuoteClose = new Entity("quoteclose")
{
Attributes = new AttributeCollection
{
{ "quoteid", quote.ToEntityReference() }
}
["quoteid"] = quote.ToEntityReference()
},
Status = new OptionSetValue(1)
Status = StatusCanceled
};

executor.Execute(req, context);

quote = service.Retrieve("quote", quote.Id, new ColumnSet(true));

Assert.Equal(new OptionSetValue(1), quote.GetAttributeValue<OptionSetValue>("statuscode"));
Assert.Equal(StateClosed, quote.GetAttributeValue<OptionSetValue>("statecode"));
Assert.Equal(StatusCanceled, quote.GetAttributeValue<OptionSetValue>("statuscode"));
}
}
}