public void Should_return_collection_with_count_equals_to_the_given_devices_a_limit() { //Arrange var expectedLimit = 5; //Act var result = _deviceApiService.GetDevices(limit: expectedLimit); //Assert CollectionAssert.IsNotEmpty(result); result.Count.ShouldEqual(expectedLimit); }
public void Should_return_only_devices_after_id_is_sorted_when_called_with_valid_since_id() { //Arrange int sinceId = 3; var expectedCollection = _devices.Where(x => x.Id > sinceId).OrderBy(x => x.Id); //Act var result = _deviceApiService.GetDevices(sinceId: sinceId); //Assert CollectionAssert.IsNotEmpty(result); Assert.IsTrue(result.Select(x => x.Id).SequenceEqual(expectedCollection.Select(x => x.Id))); }
public void Should_return_devices_sorted_by_id_when_devices_created_after_given_date() { //Arrange DateTime createdAtMinDate = _baseDate.AddMonths(5); var expectedCollection = _devices.Where(x => x.CreatedOnUtc > createdAtMinDate).OrderBy(x => x.Id); //Act var result = _deviceApiService.GetDevices(createdAtMin: createdAtMinDate); //Assert CollectionAssert.IsNotEmpty(result); result.Count.ShouldEqual(expectedCollection.Count()); Assert.IsTrue(result.Select(x => x.Id).SequenceEqual(expectedCollection.Select(x => x.Id))); }
public void Should_return_part_of_collection_corresponds_to_page_when_given_limited_devices_collection() { //Arrange var limit = 5; var page = 6; var expectedCollection = new ApiList <Device>(_devices.AsQueryable(), page - 1, limit); //Act var result = _deviceApiService.GetDevices(limit: limit, page: page); //Assert CollectionAssert.IsNotEmpty(result); result.Count.ShouldEqual(expectedCollection.Count); Assert.IsTrue(result.Select(x => x.Id).SequenceEqual(expectedCollection.Select(x => x.Id))); }
public void Should_return_them_sorted_by_id_when_given_devices_with_specified_ids() { //Arrange var idsCollection = new List <int>() { 1, 5 }; //Act var result = _deviceApiService.GetDevices(ids: idsCollection); //Assert CollectionAssert.IsNotEmpty(result); result[0].Id.ShouldEqual(idsCollection[0]); result[1].Id.ShouldEqual(idsCollection[1]); }
public void Should_return_them_with_sorted_id_when_given_devices_exist() { //Act var result = _deviceApiService.GetDevices(); //Assert result.ShouldNotBeNull(); result.Count.ShouldEqual(2); result[0].SerialNo.ShouldEqual("SE2"); result[1].ModelNo.ShouldEqual("MD1"); result[0].Id.ShouldEqual(2); }
public void Should_return_them_sorted_by_id_when_ask_for_devices_status() { //Arrange var expectedCollection = _devices.Where(x => x.Status == "2").OrderBy(x => x.Id); //Act var result = _deviceApiService.GetDevices(status: "2"); //Assert CollectionAssert.IsNotEmpty(result); result.Select(x => x.Id).SequenceEqual(expectedCollection.Select(x => x.Id)).ShouldBeTrue(); }
public void Should_return_empty_collection_when_no_given_devices_exist() { //Arrange _deviceRepository.Setup(x => x.Table).Returns(new List <Device>().AsQueryable); _deviceApiService = new DeviceApiService(_tenantMappingService.Object, _deviceRepository.Object); //Act var result = _deviceApiService.GetDevices(); //Assert result.Count.ShouldEqual(0); }