public void RequestIdInResponseShouldMatchWithRequestParam()
        {
            // given
            var id         = int.Parse(sourcesystem.ToMdmId().Identifier);
            var mdmReqInfo = new MdmRequestInfo {
                RequestId = "Test123"
            };
            // when
            var response = MdmService.Get <SourceSystem>(id);
            var entity   = response.Message;

            entity.Identifiers = new MdmIdList()
            {
                entity.Identifiers.SystemId()
            };

            // then
            response = MdmService.Update(id, entity, response.Tag, mdmReqInfo);
            Assert.IsTrue(response.IsValid && response.RequestId == mdmReqInfo.RequestId, "###Error : " + response.Code + " : " + (response.Fault == null ? string.Empty : response.Fault.Message + " : " + response.Fault.Reason));

            var mappingId         = Guid.NewGuid().ToString();
            var mdmUpdateResponse = MdmService.CreateMapping <SourceSystem>(id, new MdmId {
                SystemName = "Endur", Identifier = mappingId
            }, mdmReqInfo);

            Assert.IsTrue(mdmUpdateResponse.IsValid && mdmUpdateResponse.RequestId == mdmReqInfo.RequestId, "###Error : " + response.Code + " : " + (response.Fault == null ? string.Empty : response.Fault.Message + " : " + response.Fault.Reason));

            if (mdmUpdateResponse.Message != null && mdmUpdateResponse.Message.MappingId.HasValue)
            {
                var mdmDeleteResponse = MdmService.DeleteMapping <SourceSystem>(id,
                                                                                (int)mdmUpdateResponse.Message.MappingId.Value, mdmReqInfo);
                Assert.IsTrue(mdmDeleteResponse.IsValid && mdmDeleteResponse.RequestId == mdmReqInfo.RequestId, "###Error : " + response.Code + " : " + (response.Fault == null ? string.Empty : response.Fault.Message + " : " + response.Fault.Reason));
            }
        }
        public void ShouldFailUpdateWhenETagDiffers()
        {
            // given
            var id = int.Parse(sourcesystem.ToMdmId().Identifier);

            // when
            var response = MdmService.Get <SourceSystem>(id);

            // then
            response = MdmService.Update(id, response.Message, "\"999888777666555\"");
            Assert.IsFalse(response.IsValid);
            Assert.AreEqual(HttpStatusCode.PreconditionFailed, response.Code);
            Assert.AreEqual("Exception of type 'EnergyTrading.Mdm.Services.VersionConflictException' was thrown.", response.Fault.Message);
        }
        public void ShouldSucceedUpdateWhenETagMatches()
        {
            // given
            var id = int.Parse(sourcesystem.ToMdmId().Identifier);

            // when
            var response = MdmService.Get <SourceSystem>(id);
            var entity   = response.Message;

            entity.Identifiers = new MdmIdList()
            {
                entity.Identifiers.SystemId()
            };

            // then
            response = MdmService.Update(id, entity, response.Tag);

            Assert.IsTrue(response.IsValid, "###Error : " + response.Code + " : " + (response.Fault == null ? string.Empty : response.Fault.Message + " : " + response.Fault.Reason));
        }