public void GivenContextWithObserverAttachedThatThrowsInvalidOperationException_WhenNotifyingLocationCalculationsElementInEnumerationToObserve_ThenNoExceptionThrown()
        {
            // Given
            var mockRepository = new MockRepository();
            var observer       = mockRepository.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver()).Do((Action)(() => throw new InvalidOperationException()));
            mockRepository.ReplayAll();

            var observable = new TestObservable();
            var locationCalculationsEnumerationToObserve = new ObservableList <IObservable>
            {
                observable
            };

            var context = new TestLocationCalculationsContext(new object(), locationCalculationsEnumerationToObserve);

            context.Attach(observer);

            // When
            observable.NotifyObservers();

            // Then
            mockRepository.VerifyAll();
        }
        public void GivenContextWithObserverAttached_WhenNotifyingLocationCalculationsElementInEnumerationToObserve_ThenObserverCorrectlyNotified()
        {
            // Given
            var mockRepository = new MockRepository();
            var observer       = mockRepository.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mockRepository.ReplayAll();

            var observable = new TestObservable();
            var locationCalculationsEnumerationToObserve = new ObservableList <IObservable>
            {
                observable
            };

            var context = new TestLocationCalculationsContext(new object(), locationCalculationsEnumerationToObserve);

            context.Attach(observer);

            // When
            observable.NotifyObservers();

            // Then
            mockRepository.VerifyAll();
        }
        public void Constructor_ExpectedValues()
        {
            // Call
            var context = new TestLocationCalculationsContext(new object(), new ObservableList <IObservable>());

            // Assert
            Assert.IsInstanceOf <WrappedObjectContextBase <object> >(context);
            Assert.IsInstanceOf <IObservable>(context);
            Assert.IsEmpty(context.Observers);
        }
        public void GivenContext_WhenObserverAttached_ThenExpectedValues()
        {
            // Given
            var mockRepository = new MockRepository();
            var observer       = mockRepository.StrictMock <IObserver>();

            mockRepository.ReplayAll();

            var context = new TestLocationCalculationsContext(new object(), new ObservableList <IObservable>());

            // When
            context.Attach(observer);

            // Then
            Assert.AreEqual(1, context.Observers.Count());
            Assert.AreSame(observer, context.Observers.ElementAt(0));
            mockRepository.VerifyAll();
        }
        public void GivenContext_WhenDetachingAttachedObserver_ThenExpectedValues()
        {
            // Given
            var mockRepository = new MockRepository();
            var observer       = mockRepository.StrictMock <IObserver>();

            mockRepository.ReplayAll();

            var context = new TestLocationCalculationsContext(new object(), new ObservableList <IObservable>());

            context.Attach(observer);

            // When
            context.Detach(observer);

            // Then
            Assert.IsEmpty(context.Observers);
            mockRepository.VerifyAll();
        }