Skip to content

How to use BeEquivalentTo for 2 DTOs, both having an Id property, but one of type Guid, the other with this same Guid converted to string #2672

Discussion options

You must be logged in to vote

Well I played a little more with the material that @IT-VBFK gave me. The following is the least ugly solution that I could come with... but I am not even sure it is worth the trouble:

public class PocoContract
{
	public Guid Id { get; set; }
	public decimal Amount { get; set; }
	public string Currency { get; set; }
}

public class ProtobufContract
{
	public string Id { get; set; }
	public float Amount { get; set; }
	public string Currency { get; set; }
}

public class ContractFixture
{
	[Fact]
	public void MessagesAreEquivalent()
	{
		var poco = new PocoContract { Id = Guid.NewGuid(), Amount = 123.45M, Currency = "EUR" };
		var proto = new ProtobufContract { Id = poco.Id.ToString(), Amount =

Replies: 6 comments 15 replies

Comment options

You must be logged in to vote
3 replies
@icraftsoftware
Comment options

@IT-VBFK
Comment options

@IT-VBFK
Comment options

Comment options

You must be logged in to vote
2 replies
@IT-VBFK
Comment options

@icraftsoftware
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@icraftsoftware
Comment options

@icraftsoftware
Comment options

@ITaluone
Comment options

Comment options

You must be logged in to vote
4 replies
@icraftsoftware
Comment options

@dennisdoomen
Comment options

@icraftsoftware
Comment options

@dennisdoomen
Comment options

Comment options

You must be logged in to vote
3 replies
@ITaluone
Comment options

@icraftsoftware
Comment options

@dennisdoomen
Comment options

Answer selected by icraftsoftware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants