public async Task VerifythatReloadSynchronizeTheAssembler()
        {
            var updatedTel    = new CDP4Common.DTO.TelephoneNumber(this.dalOutputs.OfType <CDP4Common.DTO.TelephoneNumber>().First().Iid, 100);
            var eventReceived = false;

            var uriQueryAttMock = new Mock <IQueryAttributes>();

            uriQueryAttMock.Setup(x => x.RevisionNumber).Returns(0);

            // returns the dtos only if revisionNumber == 0
            var readTaskCompletionSource = new TaskCompletionSource <IEnumerable <Thing> >();

            readTaskCompletionSource.SetResult(new List <Thing> {
                updatedTel
            });
            this.mockedDal.Setup(x => x.Read(It.IsAny <Thing>(), It.IsAny <CancellationToken>(), It.Is <IQueryAttributes>(query => query.RevisionNumber == 0))).Returns(readTaskCompletionSource.Task);

            await this.session.Open();

            CDPMessageBus.Current.Listen <ObjectChangedEvent>(typeof(TelephoneNumber)).Subscribe(x =>
            {
                eventReceived = true;
            });

            await this.session.Reload();

            Assert.IsTrue(eventReceived);
        }
        public void SetUp()
        {
            this.dalOutputs = new List <Thing>();

            this.sieSiteDirectoryDto = new CDP4Common.DTO.SiteDirectory(Guid.NewGuid(), 22);
            this.person = new CDP4Common.DTO.Person(Guid.NewGuid(), 22)
            {
                ShortName = "John", GivenName = "John", Password = "******", IsActive = true
            };

            var phone1 = new CDP4Common.DTO.TelephoneNumber(Guid.NewGuid(), 22)
            {
                Value = "123"
            };

            phone1.VcardType.Add(VcardTelephoneNumberKind.HOME);
            var phone2 = new CDP4Common.DTO.TelephoneNumber(Guid.NewGuid(), 22)
            {
                Value = "456"
            };

            phone2.VcardType.Add(VcardTelephoneNumberKind.WORK);
            var phone3 = new CDP4Common.DTO.TelephoneNumber(Guid.NewGuid(), 22)
            {
                Value = "789"
            };

            phone3.VcardType.Add(VcardTelephoneNumberKind.FAX);

            this.sieSiteDirectoryDto.Person.Add(this.person.Iid);

            this.person.TelephoneNumber.Add(phone1.Iid);
            this.person.TelephoneNumber.Add(phone2.Iid);
            this.person.TelephoneNumber.Add(phone3.Iid);

            this.dalOutputs.Add(this.sieSiteDirectoryDto);
            this.dalOutputs.Add(this.person);
            this.dalOutputs.Add(phone1);
            this.dalOutputs.Add(phone2);
            this.dalOutputs.Add(phone3);

            this.uri = new Uri("http://www.rheagroup.com/");
            var credentials = new Credentials("John", "Doe", this.uri);

            this.mockedDal = new Mock <IDal>();
            this.mockedDal.SetupProperty(d => d.Session);

            this.session = new Session(this.mockedDal.Object, credentials);

            var openTaskCompletionSource = new TaskCompletionSource <IEnumerable <Thing> >();

            openTaskCompletionSource.SetResult(this.dalOutputs);
            this.mockedDal.Setup(x => x.Open(It.IsAny <Credentials>(), It.IsAny <CancellationToken>())).Returns(openTaskCompletionSource.Task);
        }