Пример #1
0
        public async void TestGetAlbumsAsync()
        {
            var data = await _albumsController.GetAlbumsAsync();

            Assert.IsAssignableFrom <List <AlbumDto> >(data);
            bool IsValid = data[0].ErrorMessage == null ? true : false;

            Assert.True(IsValid);
        }
        public async void TestGetAlbumsAsync()
        {
            // 2. Act: Run the SUT (software under test - the actual testing code)
            var data = await _albumsController.GetAlbumsAsync();

            // 3. Assert: Check and verify the result.
            Assert.IsAssignableFrom <List <AlbumDto> >(data);
            bool IsValid = data[0].ErrorMessage == null ? true : false;

            Assert.True(IsValid);
        }
Пример #3
0
        public async void TestGetAlbumsAsync()
        {
            // 2. Act: Run the SUT (software under test - the actual testing code)
            var data = await _controller.GetAlbumsAsync();

            // 3. Assert: Check and verify the result.
            Assert.IsAssignableFrom <IActionResult>(data);

            bool IsValid = (int)data.GetType().GetProperty("StatusCode").GetValue(data, null) == 200;

            Assert.True(IsValid);

            var albums = (HashSet <AlbumViewModel>)data.GetType().GetProperty("Value").GetValue(data);

            IsValid = albums.ElementAt(0).ErrorMessage?.FirstOrDefault() == null;
            Assert.True(IsValid);
        }