예제 #1
0
 public EditRegionViewModel(IEnumerable<Variety> varieties, Variety variety, GeographicRegion region)
 {
     _title = "Edit Region";
     _varieties = new ReadOnlyList<VarietyViewModel>(varieties.Select(v => new VarietyViewModel(v)).OrderBy(vm => vm.Name).ToArray());
     _selectedVariety = _varieties.First(vm => vm.DomainVariety == variety);
     _description = region.Description;
 }
예제 #2
0
 public EditRegionViewModel(IEnumerable <Variety> varieties, Variety variety, GeographicRegion region)
 {
     _title           = "Edit Region";
     _varieties       = new ReadOnlyList <VarietyViewModel>(varieties.Select(v => new VarietyViewModel(v)).OrderBy(vm => vm.Name).ToArray());
     _selectedVariety = _varieties.First(vm => vm.DomainVariety == variety);
     _description     = region.Description;
 }
예제 #3
0
        public void List_First()
        {
            var list = new int[] { 3 };

            Assert.AreEqual(3, ReadOnlyList.First(list));
            list = new int[] { 9, 3, 1 };
            Assert.AreEqual(9, ReadOnlyList.First(list));
        }
        public void First_With_Empty_Must_Throw(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueReadOnlyList(source);

            // Act
            Action action = () => _ = ReadOnlyList
                                      .First <Wrap.ValueReadOnlyList <int>, int>(wrapped);

            // Assert
            _ = action.Must()
                .Throw <InvalidOperationException>()
                .EvaluateTrue(exception => exception.Message == "Sequence contains no elements");
        }
        public void First_With_ValidData_Must_Succeed(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueReadOnlyList(source);
            var expected =
                System.Linq.Enumerable.First(source);

            // Act
            var result = ReadOnlyList
                         .First <Wrap.ValueReadOnlyList <int>, int>(wrapped);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }