ActivatedValueTests.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (c) The Perspex Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Reactive.Linq;
  6. using System.Reactive.Subjects;
  7. using Xunit;
  8. namespace Perspex.Styling.UnitTests
  9. {
  10. public class ActivatedValueTests
  11. {
  12. [Fact]
  13. public void Should_Produce_Correct_Values()
  14. {
  15. var activator = new BehaviorSubject<bool>(false);
  16. var target = new ActivatedValue(activator, 1, string.Empty);
  17. var result = new List<object>();
  18. target.Subscribe(x => result.Add(x));
  19. activator.OnNext(true);
  20. activator.OnNext(false);
  21. Assert.Equal(new[] { PerspexProperty.UnsetValue, 1, PerspexProperty.UnsetValue }, result);
  22. }
  23. [Fact]
  24. public void Should_Complete_When_Activator_Completes()
  25. {
  26. var activator = new BehaviorSubject<bool>(false);
  27. var target = new ActivatedValue(activator, 1, string.Empty);
  28. var completed = false;
  29. target.Subscribe(_ => { }, () => completed = true);
  30. activator.OnCompleted();
  31. Assert.True(completed);
  32. }
  33. }
  34. }