diff --git a/.github/workflows/nuget-publish.yml b/.github/workflows/nuget-publish.yml index d9aa0a0..da2b47d 100644 --- a/.github/workflows/nuget-publish.yml +++ b/.github/workflows/nuget-publish.yml @@ -26,12 +26,18 @@ jobs: with: dotnet-version: 8.0.x + - name: Install Android workload + run: dotnet workload install android --ignore-failed-sources + - name: Restore run: dotnet restore ./src/Main/RSSDP.sln - name: Build run: dotnet build ./src/Main/RSSDP.sln --configuration Release --no-restore + - name: Test + run: dotnet test ./src/Main/RSSDP.sln --configuration Release --no-build --logger "trx;LogFileName=test_results.trx" --results-directory TestResults + - name: Determine Version and Project Path id: meta shell: bash @@ -56,7 +62,7 @@ jobs: - name: Publish to NuGet.org env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - run: dotnet nuget push "./artifacts/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key "$NUGET_API_KEY" --skip-duplicate + run: dotnet nuget push artifacts\Rssdp.*.nupkg --source https://api.nuget.org/v3/index.json --api-key $env:NUGET_API_KEY --skip-duplicate - name: Upload Package Artifact if: always() diff --git a/.github/workflows/pr-gate.yml b/.github/workflows/pr-gate.yml index 7c8871e..d1891a9 100644 --- a/.github/workflows/pr-gate.yml +++ b/.github/workflows/pr-gate.yml @@ -23,6 +23,9 @@ jobs: 8.0.x 6.0.x + - name: Install Android workload + run: dotnet workload install android --ignore-failed-sources + - name: Cache NuGet uses: actions/cache@v4 with: @@ -38,13 +41,12 @@ jobs: run: dotnet build ./src/Main/RSSDP.sln --configuration Release --no-restore - name: Test - run: dotnet test ./src/Main/RSSDP.sln --configuration Release --no-build --logger "trx;LogFileName=test_results.trx" + run: dotnet test ./src/Main/RSSDP.sln --configuration Release --no-build --logger "trx;LogFileName=test_results.trx" --results-directory TestResults - name: Publish Test Results if: always() uses: actions/upload-artifact@v4 with: name: test-results - path: | - **/TestResults/*.trx - **/TestResults/**/*.trx + path: TestResults/**/*.trx + if-no-files-found: warn diff --git a/docs/manifest.json b/docs/manifest.json index f35754c..bfb4b3d 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -24,7 +24,7 @@ "hash": "99ckxg02dafTH9nwfNcM3+EW6+6OT7eAntv7e+eAw1M=" } }, - "is_incremental": false, + "is_incremental": true, "version": "" }, { @@ -36,7 +36,7 @@ "hash": "lA+D0ov1AuxIeiIRjNe6INd51sXFRnKwse3JvVHtBMc=" } }, - "is_incremental": false, + "is_incremental": true, "version": "" }, { @@ -72,7 +72,7 @@ "hash": "FjfzVTFVpsd29KnX7ZXM5XpUSA0PbivvdLDwaNXbtRM=" } }, - "is_incremental": false, + "is_incremental": true, "version": "" }, { @@ -84,7 +84,7 @@ "hash": "sOWMwUlh5r2IlSoPR4cwUCPGj1GSd86uEc1W7GJZXMU=" } }, - "is_incremental": false, + "is_incremental": true, "version": "" }, { @@ -120,7 +120,7 @@ "hash": "eWz9C1JMOjv6zeqLvYtDmDJBMO1Qx4HMSBRf+XtVIoo=" } }, - "is_incremental": false, + "is_incremental": true, "version": "" }, { @@ -599,32 +599,30 @@ "hash": "f9a4x1d92blNB6PDNbfGHtTJFnV93H9sBpeptN0ZqTo=" } }, - "is_incremental": false, + "is_incremental": true, "version": "" } ], "incremental_info": [ { "status": { - "can_incremental": false, - "details": "Cannot build incrementally because last build info is missing.", + "can_incremental": true, "incrementalPhase": "build", "total_file_count": 0, - "skipped_file_count": 0, - "full_build_reason_code": "NoAvailableBuildCache" + "skipped_file_count": 0 }, "processors": { "ConceptualDocumentProcessor": { - "can_incremental": false, + "can_incremental": true, "incrementalPhase": "build", "total_file_count": 1, - "skipped_file_count": 0 + "skipped_file_count": 1 }, "ManagedReferenceDocumentProcessor": { - "can_incremental": false, + "can_incremental": true, "incrementalPhase": "build", "total_file_count": 48, - "skipped_file_count": 0 + "skipped_file_count": 14 }, "ResourceDocumentProcessor": { "can_incremental": false, @@ -644,8 +642,8 @@ }, { "status": { - "can_incremental": false, - "details": "Cannot support incremental post processing, the reason is: last post processor info is null.", + "can_incremental": true, + "details": "Can support incremental post processing.", "incrementalPhase": "postProcessing", "total_file_count": 0, "skipped_file_count": 0 diff --git a/src/Main/Lib/HttpRequestParser.cs b/src/Main/Lib/HttpRequestParser.cs index 9571317..17eb8ca 100644 --- a/src/Main/Lib/HttpRequestParser.cs +++ b/src/Main/Lib/HttpRequestParser.cs @@ -37,9 +37,11 @@ public override System.Net.Http.HttpRequestMessage Parse(string data) return retVal; } - finally + catch { retVal?.Dispose(); + + throw; } } diff --git a/src/Main/Lib/Rssdp.csproj b/src/Main/Lib/Rssdp.csproj index 33fba46..77c6dde 100644 --- a/src/Main/Lib/Rssdp.csproj +++ b/src/Main/Lib/Rssdp.csproj @@ -9,7 +9,7 @@ True Rssdp Rssdp - $(VersionPrefix)5.0.0-beta2 + $(VersionPrefix)5.0.0-beta3 Troy Willmot Yortw Really Simple Service Discovery Protocol - a 100% .Net implementation of the SSDP protocol for publishing custom/basic devices, and discovering all device types on a network. @@ -53,6 +53,7 @@ 11.0 Really Simple Service Discovery Protocol True + snupkg diff --git a/src/Main/Lib/api/Rssdp.ISsdpLogger.yml b/src/Main/Lib/api/Rssdp.ISsdpLogger.yml index 03c9d60..19cc939 100644 --- a/src/Main/Lib/api/Rssdp.ISsdpLogger.yml +++ b/src/Main/Lib/api/Rssdp.ISsdpLogger.yml @@ -19,7 +19,7 @@ items: source: id: ISsdpLogger path: '' - startLine: 2000 + startLine: 2002 assemblies: - cs.temp.dll namespace: Rssdp @@ -48,7 +48,7 @@ items: source: id: LogInfo path: '' - startLine: 2007 + startLine: 2009 assemblies: - cs.temp.dll namespace: Rssdp @@ -76,7 +76,7 @@ items: source: id: LogVerbose path: '' - startLine: 2013 + startLine: 2015 assemblies: - cs.temp.dll namespace: Rssdp @@ -104,7 +104,7 @@ items: source: id: LogWarning path: '' - startLine: 2019 + startLine: 2021 assemblies: - cs.temp.dll namespace: Rssdp @@ -132,7 +132,7 @@ items: source: id: LogError path: '' - startLine: 2025 + startLine: 2027 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.HttpRequestParser.yml b/src/Main/Lib/api/Rssdp.Infrastructure.HttpRequestParser.yml index b1e6eda..4ac43d2 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.HttpRequestParser.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.HttpRequestParser.yml @@ -102,7 +102,7 @@ items: source: id: ParseStatusLine path: '' - startLine: 1553 + startLine: 1555 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -140,7 +140,7 @@ items: source: id: IsContentHeader path: '' - startLine: 1574 + startLine: 1576 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.HttpResponseParser.yml b/src/Main/Lib/api/Rssdp.Infrastructure.HttpResponseParser.yml index 1de4467..33cae95 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.HttpResponseParser.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.HttpResponseParser.yml @@ -18,7 +18,7 @@ items: source: id: HttpResponseParser path: '' - startLine: 1593 + startLine: 1595 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -65,7 +65,7 @@ items: source: id: Parse path: '' - startLine: 1612 + startLine: 1614 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -103,7 +103,7 @@ items: source: id: IsContentHeader path: '' - startLine: 1639 + startLine: 1641 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -141,7 +141,7 @@ items: source: id: ParseStatusLine path: '' - startLine: 1649 + startLine: 1651 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.ISocketFactory.yml b/src/Main/Lib/api/Rssdp.Infrastructure.ISocketFactory.yml index 69ada7b..a8add8e 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.ISocketFactory.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.ISocketFactory.yml @@ -18,7 +18,7 @@ items: source: id: ISocketFactory path: '' - startLine: 1703 + startLine: 1705 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -47,7 +47,7 @@ items: source: id: CreateUdpSocket path: '' - startLine: 1711 + startLine: 1713 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -78,7 +78,7 @@ items: source: id: CreateUdpMulticastSocket path: '' - startLine: 1719 + startLine: 1721 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -112,7 +112,7 @@ items: source: id: DeviceNetworkType path: '' - startLine: 1725 + startLine: 1727 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpCommunicationsServer.yml b/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpCommunicationsServer.yml index f225ee1..68c39c5 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpCommunicationsServer.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpCommunicationsServer.yml @@ -25,7 +25,7 @@ items: source: id: ISsdpCommunicationsServer path: '' - startLine: 1736 + startLine: 1738 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -58,7 +58,7 @@ items: source: id: RequestReceived path: '' - startLine: 1744 + startLine: 1746 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -83,7 +83,7 @@ items: source: id: ResponseReceived path: '' - startLine: 1749 + startLine: 1751 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -108,7 +108,7 @@ items: source: id: BeginListeningForBroadcasts path: '' - startLine: 1758 + startLine: 1760 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -132,7 +132,7 @@ items: source: id: StopListeningForBroadcasts path: '' - startLine: 1763 + startLine: 1765 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -156,7 +156,7 @@ items: source: id: StopListeningForResponses path: '' - startLine: 1768 + startLine: 1770 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -180,7 +180,7 @@ items: source: id: SendMessage path: '' - startLine: 1775 + startLine: 1777 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -214,7 +214,7 @@ items: source: id: IsShared path: '' - startLine: 1787 + startLine: 1789 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -245,7 +245,7 @@ items: source: id: DeviceNetworkType path: '' - startLine: 1792 + startLine: 1794 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -276,7 +276,7 @@ items: source: id: UdpSendCount path: '' - startLine: 1798 + startLine: 1800 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -309,7 +309,7 @@ items: source: id: UdpSendDelay path: '' - startLine: 1804 + startLine: 1806 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpDeviceLocator.yml b/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpDeviceLocator.yml index 2729b64..c40ec8c 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpDeviceLocator.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpDeviceLocator.yml @@ -25,7 +25,7 @@ items: source: id: ISsdpDeviceLocator path: '' - startLine: 1824 + startLine: 1826 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -62,7 +62,7 @@ items: source: id: DeviceAvailable path: '' - startLine: 1836 + startLine: 1838 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -96,7 +96,7 @@ items: source: id: DeviceUnavailable path: '' - startLine: 1845 + startLine: 1847 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -128,7 +128,7 @@ items: source: id: NotificationFilter path: '' - startLine: 1865 + startLine: 1867 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -168,7 +168,7 @@ items: source: id: IsSearching path: '' - startLine: 1874 + startLine: 1876 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -199,7 +199,7 @@ items: source: id: SearchAsync path: '' - startLine: 1886 + startLine: 1888 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -229,7 +229,7 @@ items: source: id: SearchAsync path: '' - startLine: 1900 + startLine: 1902 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -266,7 +266,7 @@ items: source: id: SearchAsync path: '' - startLine: 1919 + startLine: 1921 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -307,7 +307,7 @@ items: source: id: SearchAsync path: '' - startLine: 1927 + startLine: 1929 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -341,7 +341,7 @@ items: source: id: StartListeningForNotifications path: '' - startLine: 1941 + startLine: 1943 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -375,7 +375,7 @@ items: source: id: StopListeningForNotifications path: '' - startLine: 1954 + startLine: 1956 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpDevicePublisher.yml b/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpDevicePublisher.yml index 3430449..947567d 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpDevicePublisher.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.ISsdpDevicePublisher.yml @@ -18,7 +18,7 @@ items: source: id: ISsdpDevicePublisher path: '' - startLine: 1970 + startLine: 1972 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -53,7 +53,7 @@ items: source: id: AddDevice path: '' - startLine: 1977 + startLine: 1979 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -81,7 +81,7 @@ items: source: id: RemoveDevice path: '' - startLine: 1984 + startLine: 1986 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -109,7 +109,7 @@ items: source: id: Devices path: '' - startLine: 1990 + startLine: 1992 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.IUdpSocket.yml b/src/Main/Lib/api/Rssdp.Infrastructure.IUdpSocket.yml index 4c2ed18..1de782e 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.IUdpSocket.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.IUdpSocket.yml @@ -17,7 +17,7 @@ items: source: id: IUdpSocket path: '' - startLine: 2035 + startLine: 2037 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -50,7 +50,7 @@ items: source: id: ReceiveAsync path: '' - startLine: 2041 + startLine: 2043 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -77,7 +77,7 @@ items: source: id: SendTo path: '' - startLine: 2048 + startLine: 2050 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.IUpnpDeviceValidator.yml b/src/Main/Lib/api/Rssdp.Infrastructure.IUpnpDeviceValidator.yml index dc0c6cb..a796aab 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.IUpnpDeviceValidator.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.IUpnpDeviceValidator.yml @@ -18,7 +18,7 @@ items: source: id: IUpnpDeviceValidator path: '' - startLine: 2057 + startLine: 2059 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -47,7 +47,7 @@ items: source: id: GetValidationErrors path: '' - startLine: 2063 + startLine: 2065 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -77,7 +77,7 @@ items: source: id: GetValidationErrors path: '' - startLine: 2069 + startLine: 2071 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -107,7 +107,7 @@ items: source: id: ThrowIfDeviceInvalid path: '' - startLine: 2074 + startLine: 2076 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.ReceivedUdpData.yml b/src/Main/Lib/api/Rssdp.Infrastructure.ReceivedUdpData.yml index 30b7b5f..e71e23e 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.ReceivedUdpData.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.ReceivedUdpData.yml @@ -18,7 +18,7 @@ items: source: id: ReceivedUdpData path: '' - startLine: 2188 + startLine: 2190 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -59,7 +59,7 @@ items: source: id: Buffer path: '' - startLine: 2193 + startLine: 2195 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -92,7 +92,7 @@ items: source: id: ReceivedBytes path: '' - startLine: 2198 + startLine: 2200 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -125,7 +125,7 @@ items: source: id: ReceivedFrom path: '' - startLine: 2203 + startLine: 2205 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.RequestReceivedEventArgs.yml b/src/Main/Lib/api/Rssdp.Infrastructure.RequestReceivedEventArgs.yml index 26f7f59..167d417 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.RequestReceivedEventArgs.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.RequestReceivedEventArgs.yml @@ -18,7 +18,7 @@ items: source: id: RequestReceivedEventArgs path: '' - startLine: 2215 + startLine: 2217 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -63,7 +63,7 @@ items: source: id: .ctor path: '' - startLine: 2232 + startLine: 2234 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -98,7 +98,7 @@ items: source: id: Message path: '' - startLine: 2245 + startLine: 2247 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -131,7 +131,7 @@ items: source: id: ReceivedFrom path: '' - startLine: 2253 + startLine: 2255 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.ResponseReceivedEventArgs.yml b/src/Main/Lib/api/Rssdp.Infrastructure.ResponseReceivedEventArgs.yml index 307c60d..e6f2cf0 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.ResponseReceivedEventArgs.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.ResponseReceivedEventArgs.yml @@ -18,7 +18,7 @@ items: source: id: ResponseReceivedEventArgs path: '' - startLine: 2270 + startLine: 2272 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -63,7 +63,7 @@ items: source: id: .ctor path: '' - startLine: 2287 + startLine: 2289 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -98,7 +98,7 @@ items: source: id: Message path: '' - startLine: 2300 + startLine: 2302 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -131,7 +131,7 @@ items: source: id: ReceivedFrom path: '' - startLine: 2308 + startLine: 2310 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.SsdpCommunicationsServer.yml b/src/Main/Lib/api/Rssdp.Infrastructure.SsdpCommunicationsServer.yml index 2f62b3b..2fdadda 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.SsdpCommunicationsServer.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.SsdpCommunicationsServer.yml @@ -29,7 +29,7 @@ items: source: id: SsdpCommunicationsServer path: '' - startLine: 2609 + startLine: 2611 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -80,7 +80,7 @@ items: source: id: RequestReceived path: '' - startLine: 2654 + startLine: 2656 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -111,7 +111,7 @@ items: source: id: ResponseReceived path: '' - startLine: 2659 + startLine: 2661 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -142,7 +142,7 @@ items: source: id: UdpSendCount path: '' - startLine: 2669 + startLine: 2671 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -180,7 +180,7 @@ items: source: id: UdpSendDelay path: '' - startLine: 2675 + startLine: 2677 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -218,7 +218,7 @@ items: source: id: .ctor path: '' - startLine: 2686 + startLine: 2688 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -254,7 +254,7 @@ items: source: id: .ctor path: '' - startLine: 2697 + startLine: 2699 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -293,7 +293,7 @@ items: source: id: .ctor path: '' - startLine: 2710 + startLine: 2712 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -338,7 +338,7 @@ items: source: id: BeginListeningForBroadcasts path: '' - startLine: 2735 + startLine: 2737 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -372,7 +372,7 @@ items: source: id: StopListeningForBroadcasts path: '' - startLine: 2752 + startLine: 2754 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -406,7 +406,7 @@ items: source: id: SendMessage path: '' - startLine: 2773 + startLine: 2775 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -453,7 +453,7 @@ items: source: id: StopListeningForResponses path: '' - startLine: 2792 + startLine: 2794 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -487,7 +487,7 @@ items: source: id: IsShared path: '' - startLine: 2814 + startLine: 2816 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -523,7 +523,7 @@ items: source: id: DeviceNetworkType path: '' - startLine: 2823 + startLine: 2825 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -558,7 +558,7 @@ items: source: id: Dispose path: '' - startLine: 2833 + startLine: 2835 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.SsdpConstants.yml b/src/Main/Lib/api/Rssdp.Infrastructure.SsdpConstants.yml index 25d90c8..04d7567 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.SsdpConstants.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.SsdpConstants.yml @@ -30,7 +30,7 @@ items: source: id: SsdpConstants path: '' - startLine: 3059 + startLine: 3061 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -70,7 +70,7 @@ items: source: id: MulticastLinkLocalAddressV6 path: '' - startLine: 3064 + startLine: 3066 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -101,7 +101,7 @@ items: source: id: MulticastLocalAdminAddress path: '' - startLine: 3068 + startLine: 3070 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -132,7 +132,7 @@ items: source: id: MulticastPort path: '' - startLine: 3072 + startLine: 3074 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -163,7 +163,7 @@ items: source: id: SsdpDefaultMulticastTimeToLive path: '' - startLine: 3076 + startLine: 3078 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -194,7 +194,7 @@ items: source: id: MulticastLocalAdminEndpoint path: '' - startLine: 3081 + startLine: 3083 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -227,7 +227,7 @@ items: source: id: DefaultUdpSocketBufferSize path: '' - startLine: 3093 + startLine: 3095 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -258,7 +258,7 @@ items: source: id: MaxUdpSocketBufferSize path: '' - startLine: 3097 + startLine: 3099 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -289,7 +289,7 @@ items: source: id: UpnpDeviceTypeNamespace path: '' - startLine: 3102 + startLine: 3104 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -320,7 +320,7 @@ items: source: id: UpnpDeviceTypeRootDevice path: '' - startLine: 3106 + startLine: 3108 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -351,7 +351,7 @@ items: source: id: PnpDeviceTypeRootDevice path: '' - startLine: 3111 + startLine: 3113 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -382,7 +382,7 @@ items: source: id: UpnpDeviceTypeBasicDevice path: '' - startLine: 3115 + startLine: 3117 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -413,7 +413,7 @@ items: source: id: DefaultUdpResendCount path: '' - startLine: 3127 + startLine: 3129 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -445,7 +445,7 @@ items: source: id: PublisherActivitySourceName path: '' - startLine: 3134 + startLine: 3136 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -476,7 +476,7 @@ items: source: id: LocatorActivitySourceName path: '' - startLine: 3139 + startLine: 3141 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -507,7 +507,7 @@ items: source: id: DefaultUdpResendDelay path: '' - startLine: 3148 + startLine: 3150 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.SsdpDeviceLocatorBase.yml b/src/Main/Lib/api/Rssdp.Infrastructure.SsdpDeviceLocatorBase.yml index ee3e6a8..2548791 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.SsdpDeviceLocatorBase.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.SsdpDeviceLocatorBase.yml @@ -30,7 +30,7 @@ items: source: id: SsdpDeviceLocatorBase path: '' - startLine: 4352 + startLine: 4354 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -83,7 +83,7 @@ items: source: id: .ctor path: '' - startLine: 4385 + startLine: 4387 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -115,7 +115,7 @@ items: source: id: DeviceAvailable path: '' - startLine: 4416 + startLine: 4418 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -155,7 +155,7 @@ items: source: id: DeviceUnavailable path: '' - startLine: 4431 + startLine: 4433 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -196,7 +196,7 @@ items: source: id: SearchAsync path: '' - startLine: 4444 + startLine: 4446 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -233,7 +233,7 @@ items: source: id: SearchAsync path: '' - startLine: 4461 + startLine: 4463 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -276,7 +276,7 @@ items: source: id: SearchAsync path: '' - startLine: 4472 + startLine: 4474 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -316,7 +316,7 @@ items: source: id: SearchAsync path: '' - startLine: 4494 + startLine: 4496 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -364,7 +364,7 @@ items: source: id: StartListeningForNotifications path: '' - startLine: 4587 + startLine: 4589 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -406,7 +406,7 @@ items: source: id: StopListeningForNotifications path: '' - startLine: 4610 + startLine: 4612 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -448,7 +448,7 @@ items: source: id: OnDeviceAvailable path: '' - startLine: 4625 + startLine: 4627 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -488,7 +488,7 @@ items: source: id: OnDeviceUnavailable path: '' - startLine: 4638 + startLine: 4640 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -528,7 +528,7 @@ items: source: id: ActivitySource path: '' - startLine: 4652 + startLine: 4654 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -561,7 +561,7 @@ items: source: id: IsSearching path: '' - startLine: 4663 + startLine: 4665 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -597,7 +597,7 @@ items: source: id: NotificationFilter path: '' - startLine: 4683 + startLine: 4685 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -642,7 +642,7 @@ items: source: id: Dispose path: '' - startLine: 4697 + startLine: 4699 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.SsdpDevicePublisherBase.yml b/src/Main/Lib/api/Rssdp.Infrastructure.SsdpDevicePublisherBase.yml index 66f8601..097486b 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.SsdpDevicePublisherBase.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.SsdpDevicePublisherBase.yml @@ -27,7 +27,7 @@ items: source: id: SsdpDevicePublisherBase path: '' - startLine: 5592 + startLine: 5594 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -80,7 +80,7 @@ items: source: id: .ctor path: '' - startLine: 5682 + startLine: 5684 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -118,7 +118,7 @@ items: source: id: .ctor path: '' - startLine: 5693 + startLine: 5695 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -159,7 +159,7 @@ items: source: id: .ctor path: '' - startLine: 5706 + startLine: 5708 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -203,7 +203,7 @@ items: source: id: AddDevice path: '' - startLine: 5749 + startLine: 5751 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -245,7 +245,7 @@ items: source: id: RemoveDevice path: '' - startLine: 5797 + startLine: 5799 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -284,7 +284,7 @@ items: source: id: ActivitySource path: '' - startLine: 5836 + startLine: 5838 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -317,7 +317,7 @@ items: source: id: Log path: '' - startLine: 5847 + startLine: 5849 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -351,7 +351,7 @@ items: source: id: Devices path: '' - startLine: 5855 + startLine: 5857 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -386,7 +386,7 @@ items: source: id: SupportPnpRootDevice path: '' - startLine: 5870 + startLine: 5872 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -432,7 +432,7 @@ items: source: id: StandardsMode path: '' - startLine: 5890 + startLine: 5892 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -466,7 +466,7 @@ items: source: id: NotificationBroadcastInterval path: '' - startLine: 5916 + startLine: 5918 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -500,7 +500,7 @@ items: source: id: Dispose path: '' - startLine: 5940 + startLine: 5942 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.UdpEndPoint.yml b/src/Main/Lib/api/Rssdp.Infrastructure.UdpEndPoint.yml index cb30e64..f447b9c 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.UdpEndPoint.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.UdpEndPoint.yml @@ -19,7 +19,7 @@ items: source: id: UdpEndPoint path: '' - startLine: 7616 + startLine: 7618 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -59,7 +59,7 @@ items: source: id: .ctor path: '' - startLine: 7627 + startLine: 7629 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -101,7 +101,7 @@ items: source: id: IPAddress path: '' - startLine: 7642 + startLine: 7644 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -135,7 +135,7 @@ items: source: id: Port path: '' - startLine: 7647 + startLine: 7649 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -168,7 +168,7 @@ items: source: id: ToString path: '' - startLine: 7653 + startLine: 7655 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.Infrastructure.Upnp10DeviceValidator.yml b/src/Main/Lib/api/Rssdp.Infrastructure.Upnp10DeviceValidator.yml index bb850e6..a1e654f 100644 --- a/src/Main/Lib/api/Rssdp.Infrastructure.Upnp10DeviceValidator.yml +++ b/src/Main/Lib/api/Rssdp.Infrastructure.Upnp10DeviceValidator.yml @@ -18,7 +18,7 @@ items: source: id: Upnp10DeviceValidator path: '' - startLine: 7869 + startLine: 7871 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -62,7 +62,7 @@ items: source: id: GetValidationErrors path: '' - startLine: 7883 + startLine: 7885 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -104,7 +104,7 @@ items: source: id: GetValidationErrors path: '' - startLine: 7908 + startLine: 7910 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure @@ -146,7 +146,7 @@ items: source: id: ThrowIfDeviceInvalid path: '' - startLine: 7993 + startLine: 7995 assemblies: - cs.temp.dll namespace: Rssdp.Infrastructure diff --git a/src/Main/Lib/api/Rssdp.NullLogger.yml b/src/Main/Lib/api/Rssdp.NullLogger.yml index feba12e..f74f73e 100644 --- a/src/Main/Lib/api/Rssdp.NullLogger.yml +++ b/src/Main/Lib/api/Rssdp.NullLogger.yml @@ -20,7 +20,7 @@ items: source: id: NullLogger path: '' - startLine: 2086 + startLine: 2088 assemblies: - cs.temp.dll namespace: Rssdp @@ -64,7 +64,7 @@ items: source: id: Instance path: '' - startLine: 2098 + startLine: 2100 assemblies: - cs.temp.dll namespace: Rssdp @@ -99,7 +99,7 @@ items: source: id: LogError path: '' - startLine: 2107 + startLine: 2109 assemblies: - cs.temp.dll namespace: Rssdp @@ -133,7 +133,7 @@ items: source: id: LogInfo path: '' - startLine: 2115 + startLine: 2117 assemblies: - cs.temp.dll namespace: Rssdp @@ -167,7 +167,7 @@ items: source: id: LogVerbose path: '' - startLine: 2123 + startLine: 2125 assemblies: - cs.temp.dll namespace: Rssdp @@ -201,7 +201,7 @@ items: source: id: LogWarning path: '' - startLine: 2131 + startLine: 2133 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.ServiceEventArgs.yml b/src/Main/Lib/api/Rssdp.ServiceEventArgs.yml index b588aad..2dfb9f9 100644 --- a/src/Main/Lib/api/Rssdp.ServiceEventArgs.yml +++ b/src/Main/Lib/api/Rssdp.ServiceEventArgs.yml @@ -17,7 +17,7 @@ items: source: id: ServiceEventArgs path: '' - startLine: 2325 + startLine: 2327 assemblies: - cs.temp.dll namespace: Rssdp @@ -62,7 +62,7 @@ items: source: id: .ctor path: '' - startLine: 2341 + startLine: 2343 assemblies: - cs.temp.dll namespace: Rssdp @@ -98,7 +98,7 @@ items: source: id: Service path: '' - startLine: 2355 + startLine: 2357 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SocketClosedException.yml b/src/Main/Lib/api/Rssdp.SocketClosedException.yml index 64d2cf8..7f5fef2 100644 --- a/src/Main/Lib/api/Rssdp.SocketClosedException.yml +++ b/src/Main/Lib/api/Rssdp.SocketClosedException.yml @@ -18,7 +18,7 @@ items: source: id: SocketClosedException path: '' - startLine: 2374 + startLine: 2376 assemblies: - cs.temp.dll namespace: Rssdp @@ -75,7 +75,7 @@ items: source: id: .ctor path: '' - startLine: 2379 + startLine: 2381 assemblies: - cs.temp.dll namespace: Rssdp @@ -103,7 +103,7 @@ items: source: id: .ctor path: '' - startLine: 2384 + startLine: 2386 assemblies: - cs.temp.dll namespace: Rssdp @@ -135,7 +135,7 @@ items: source: id: .ctor path: '' - startLine: 2390 + startLine: 2392 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SocketFactory.yml b/src/Main/Lib/api/Rssdp.SocketFactory.yml index 85a89e2..a43daca 100644 --- a/src/Main/Lib/api/Rssdp.SocketFactory.yml +++ b/src/Main/Lib/api/Rssdp.SocketFactory.yml @@ -19,7 +19,7 @@ items: source: id: SocketFactory path: '' - startLine: 2417 + startLine: 2419 assemblies: - cs.temp.dll namespace: Rssdp @@ -64,7 +64,7 @@ items: source: id: .ctor path: '' - startLine: 2427 + startLine: 2429 assemblies: - cs.temp.dll namespace: Rssdp @@ -96,7 +96,7 @@ items: source: id: CreateUdpSocket path: '' - startLine: 2444 + startLine: 2446 assemblies: - cs.temp.dll namespace: Rssdp @@ -133,7 +133,7 @@ items: source: id: CreateUdpMulticastSocket path: '' - startLine: 2472 + startLine: 2474 assemblies: - cs.temp.dll namespace: Rssdp @@ -173,7 +173,7 @@ items: source: id: DeviceNetworkType path: '' - startLine: 2511 + startLine: 2513 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpDevice.yml b/src/Main/Lib/api/Rssdp.SsdpDevice.yml index 68ef8df..fedd99c 100644 --- a/src/Main/Lib/api/Rssdp.SsdpDevice.yml +++ b/src/Main/Lib/api/Rssdp.SsdpDevice.yml @@ -53,7 +53,7 @@ items: source: id: SsdpDevice path: '' - startLine: 3173 + startLine: 3175 assemblies: - cs.temp.dll namespace: Rssdp @@ -103,7 +103,7 @@ items: source: id: DeviceAdded path: '' - startLine: 3197 + startLine: 3199 assemblies: - cs.temp.dll namespace: Rssdp @@ -137,7 +137,7 @@ items: source: id: DeviceRemoved path: '' - startLine: 3204 + startLine: 3206 assemblies: - cs.temp.dll namespace: Rssdp @@ -171,7 +171,7 @@ items: source: id: ServiceAdded path: '' - startLine: 3211 + startLine: 3213 assemblies: - cs.temp.dll namespace: Rssdp @@ -205,7 +205,7 @@ items: source: id: ServiceRemoved path: '' - startLine: 3218 + startLine: 3220 assemblies: - cs.temp.dll namespace: Rssdp @@ -239,7 +239,7 @@ items: source: id: .ctor path: '' - startLine: 3227 + startLine: 3229 assemblies: - cs.temp.dll namespace: Rssdp @@ -267,7 +267,7 @@ items: source: id: .ctor path: '' - startLine: 3250 + startLine: 3252 assemblies: - cs.temp.dll namespace: Rssdp @@ -310,7 +310,7 @@ items: source: id: DeviceType path: '' - startLine: 3279 + startLine: 3281 assemblies: - cs.temp.dll namespace: Rssdp @@ -351,7 +351,7 @@ items: source: id: DeviceTypeNamespace path: '' - startLine: 3298 + startLine: 3300 assemblies: - cs.temp.dll namespace: Rssdp @@ -392,7 +392,7 @@ items: source: id: DeviceVersion path: '' - startLine: 3317 + startLine: 3319 assemblies: - cs.temp.dll namespace: Rssdp @@ -433,7 +433,7 @@ items: source: id: FullDeviceType path: '' - startLine: 3335 + startLine: 3337 assemblies: - cs.temp.dll namespace: Rssdp @@ -467,7 +467,7 @@ items: source: id: Uuid path: '' - startLine: 3354 + startLine: 3356 assemblies: - cs.temp.dll namespace: Rssdp @@ -501,7 +501,7 @@ items: source: id: Udn path: '' - startLine: 3364 + startLine: 3366 assemblies: - cs.temp.dll namespace: Rssdp @@ -535,7 +535,7 @@ items: source: id: FriendlyName path: '' - startLine: 3383 + startLine: 3385 assemblies: - cs.temp.dll namespace: Rssdp @@ -569,7 +569,7 @@ items: source: id: Manufacturer path: '' - startLine: 3388 + startLine: 3390 assemblies: - cs.temp.dll namespace: Rssdp @@ -602,7 +602,7 @@ items: source: id: ManufacturerUrl path: '' - startLine: 3393 + startLine: 3395 assemblies: - cs.temp.dll namespace: Rssdp @@ -635,7 +635,7 @@ items: source: id: ModelDescription path: '' - startLine: 3399 + startLine: 3401 assemblies: - cs.temp.dll namespace: Rssdp @@ -669,7 +669,7 @@ items: source: id: ModelName path: '' - startLine: 3404 + startLine: 3406 assemblies: - cs.temp.dll namespace: Rssdp @@ -702,7 +702,7 @@ items: source: id: ModelNumber path: '' - startLine: 3409 + startLine: 3411 assemblies: - cs.temp.dll namespace: Rssdp @@ -735,7 +735,7 @@ items: source: id: ModelUrl path: '' - startLine: 3417 + startLine: 3419 assemblies: - cs.temp.dll namespace: Rssdp @@ -769,7 +769,7 @@ items: source: id: SerialNumber path: '' - startLine: 3422 + startLine: 3424 assemblies: - cs.temp.dll namespace: Rssdp @@ -802,7 +802,7 @@ items: source: id: Upc path: '' - startLine: 3430 + startLine: 3432 assemblies: - cs.temp.dll namespace: Rssdp @@ -836,7 +836,7 @@ items: source: id: PresentationUrl path: '' - startLine: 3438 + startLine: 3440 assemblies: - cs.temp.dll namespace: Rssdp @@ -870,7 +870,7 @@ items: source: id: Icons path: '' - startLine: 3445 + startLine: 3447 assemblies: - cs.temp.dll namespace: Rssdp @@ -903,7 +903,7 @@ items: source: id: Devices path: '' - startLine: 3456 + startLine: 3458 assemblies: - cs.temp.dll namespace: Rssdp @@ -941,7 +941,7 @@ items: source: id: CustomProperties path: '' - startLine: 3465 + startLine: 3467 assemblies: - cs.temp.dll namespace: Rssdp @@ -974,7 +974,7 @@ items: source: id: CustomResponseHeaders path: '' - startLine: 3480 + startLine: 3482 assemblies: - cs.temp.dll namespace: Rssdp @@ -1008,7 +1008,7 @@ items: source: id: Services path: '' - startLine: 3493 + startLine: 3495 assemblies: - cs.temp.dll namespace: Rssdp @@ -1046,7 +1046,7 @@ items: source: id: SanitizeXmlString path: '' - startLine: 3507 + startLine: 3509 assemblies: - cs.temp.dll namespace: Rssdp @@ -1084,7 +1084,7 @@ items: source: id: AddDevice path: '' - startLine: 3566 + startLine: 3568 assemblies: - cs.temp.dll namespace: Rssdp @@ -1127,7 +1127,7 @@ items: source: id: RemoveDevice path: '' - startLine: 3597 + startLine: 3599 assemblies: - cs.temp.dll namespace: Rssdp @@ -1167,7 +1167,7 @@ items: source: id: OnDeviceAdded path: '' - startLine: 3620 + startLine: 3622 assemblies: - cs.temp.dll namespace: Rssdp @@ -1206,7 +1206,7 @@ items: source: id: OnDeviceRemoved path: '' - startLine: 3631 + startLine: 3633 assemblies: - cs.temp.dll namespace: Rssdp @@ -1246,7 +1246,7 @@ items: source: id: AddService path: '' - startLine: 3650 + startLine: 3652 assemblies: - cs.temp.dll namespace: Rssdp @@ -1286,7 +1286,7 @@ items: source: id: RemoveService path: '' - startLine: 3677 + startLine: 3679 assemblies: - cs.temp.dll namespace: Rssdp @@ -1326,7 +1326,7 @@ items: source: id: OnServiceAdded path: '' - startLine: 3697 + startLine: 3699 assemblies: - cs.temp.dll namespace: Rssdp @@ -1365,7 +1365,7 @@ items: source: id: OnServiceRemoved path: '' - startLine: 3708 + startLine: 3710 assemblies: - cs.temp.dll namespace: Rssdp @@ -1405,7 +1405,7 @@ items: source: id: WriteDeviceDescriptionXml path: '' - startLine: 3721 + startLine: 3723 assemblies: - cs.temp.dll namespace: Rssdp @@ -1446,7 +1446,7 @@ items: source: id: StringToUri path: '' - startLine: 3756 + startLine: 3758 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpDeviceExtensions.yml b/src/Main/Lib/api/Rssdp.SsdpDeviceExtensions.yml index 25656ef..5354241 100644 --- a/src/Main/Lib/api/Rssdp.SsdpDeviceExtensions.yml +++ b/src/Main/Lib/api/Rssdp.SsdpDeviceExtensions.yml @@ -16,7 +16,7 @@ items: source: id: SsdpDeviceExtensions path: '' - startLine: 4202 + startLine: 4204 assemblies: - cs.temp.dll namespace: Rssdp @@ -57,7 +57,7 @@ items: source: id: ToRootDevice path: '' - startLine: 4217 + startLine: 4219 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpDeviceIcon.yml b/src/Main/Lib/api/Rssdp.SsdpDeviceIcon.yml index b601141..069c3c3 100644 --- a/src/Main/Lib/api/Rssdp.SsdpDeviceIcon.yml +++ b/src/Main/Lib/api/Rssdp.SsdpDeviceIcon.yml @@ -20,7 +20,7 @@ items: source: id: SsdpDeviceIcon path: '' - startLine: 4243 + startLine: 4245 assemblies: - cs.temp.dll namespace: Rssdp @@ -61,7 +61,7 @@ items: source: id: MimeType path: '' - startLine: 4252 + startLine: 4254 assemblies: - cs.temp.dll namespace: Rssdp @@ -98,7 +98,7 @@ items: source: id: Url path: '' - startLine: 4261 + startLine: 4263 assemblies: - cs.temp.dll namespace: Rssdp @@ -135,7 +135,7 @@ items: source: id: Width path: '' - startLine: 4267 + startLine: 4269 assemblies: - cs.temp.dll namespace: Rssdp @@ -169,7 +169,7 @@ items: source: id: Height path: '' - startLine: 4273 + startLine: 4275 assemblies: - cs.temp.dll namespace: Rssdp @@ -203,7 +203,7 @@ items: source: id: ColorDepth path: '' - startLine: 4279 + startLine: 4281 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpDeviceLocator.yml b/src/Main/Lib/api/Rssdp.SsdpDeviceLocator.yml index 92c1ad6..0473ecb 100644 --- a/src/Main/Lib/api/Rssdp.SsdpDeviceLocator.yml +++ b/src/Main/Lib/api/Rssdp.SsdpDeviceLocator.yml @@ -18,7 +18,7 @@ items: source: id: SsdpDeviceLocator path: '' - startLine: 4291 + startLine: 4293 assemblies: - cs.temp.dll namespace: Rssdp @@ -84,7 +84,7 @@ items: source: id: .ctor path: '' - startLine: 4297 + startLine: 4299 assemblies: - cs.temp.dll namespace: Rssdp @@ -112,7 +112,7 @@ items: source: id: .ctor path: '' - startLine: 4316 + startLine: 4318 assemblies: - cs.temp.dll namespace: Rssdp @@ -144,7 +144,7 @@ items: source: id: .ctor path: '' - startLine: 4332 + startLine: 4334 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpDevicePropertiesCollection.yml b/src/Main/Lib/api/Rssdp.SsdpDevicePropertiesCollection.yml index cc27ce1..bfe0c53 100644 --- a/src/Main/Lib/api/Rssdp.SsdpDevicePropertiesCollection.yml +++ b/src/Main/Lib/api/Rssdp.SsdpDevicePropertiesCollection.yml @@ -26,7 +26,7 @@ items: source: id: SsdpDevicePropertiesCollection path: '' - startLine: 5191 + startLine: 5193 assemblies: - cs.temp.dll namespace: Rssdp @@ -71,7 +71,7 @@ items: source: id: .ctor path: '' - startLine: 5205 + startLine: 5207 assemblies: - cs.temp.dll namespace: Rssdp @@ -99,7 +99,7 @@ items: source: id: .ctor path: '' - startLine: 5214 + startLine: 5216 assemblies: - cs.temp.dll namespace: Rssdp @@ -131,7 +131,7 @@ items: source: id: Add path: '' - startLine: 5232 + startLine: 5234 assemblies: - cs.temp.dll namespace: Rssdp @@ -171,7 +171,7 @@ items: source: id: Remove path: '' - startLine: 5256 + startLine: 5258 assemblies: - cs.temp.dll namespace: Rssdp @@ -217,7 +217,7 @@ items: source: id: Remove path: '' - startLine: 5276 + startLine: 5278 assemblies: - cs.temp.dll namespace: Rssdp @@ -256,7 +256,7 @@ items: source: id: Contains path: '' - startLine: 5293 + startLine: 5295 assemblies: - cs.temp.dll namespace: Rssdp @@ -291,7 +291,7 @@ items: source: id: Contains path: '' - startLine: 5310 + startLine: 5312 assemblies: - cs.temp.dll namespace: Rssdp @@ -326,7 +326,7 @@ items: source: id: Count path: '' - startLine: 5327 + startLine: 5329 assemblies: - cs.temp.dll namespace: Rssdp @@ -359,7 +359,7 @@ items: source: id: this[] path: '' - startLine: 5338 + startLine: 5340 assemblies: - cs.temp.dll namespace: Rssdp @@ -403,7 +403,7 @@ items: source: id: GetEnumerator path: '' - startLine: 5354 + startLine: 5356 assemblies: - cs.temp.dll namespace: Rssdp @@ -437,7 +437,7 @@ items: source: id: System.Collections.IEnumerable.GetEnumerator path: '' - startLine: 5370 + startLine: 5372 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpDeviceProperty.yml b/src/Main/Lib/api/Rssdp.SsdpDeviceProperty.yml index 5fcd7c5..670a13c 100644 --- a/src/Main/Lib/api/Rssdp.SsdpDeviceProperty.yml +++ b/src/Main/Lib/api/Rssdp.SsdpDeviceProperty.yml @@ -21,7 +21,7 @@ items: source: id: SsdpDeviceProperty path: '' - startLine: 5389 + startLine: 5391 assemblies: - cs.temp.dll namespace: Rssdp @@ -62,7 +62,7 @@ items: source: id: .ctor path: '' - startLine: 5397 + startLine: 5399 assemblies: - cs.temp.dll namespace: Rssdp @@ -97,7 +97,7 @@ items: source: id: .ctor path: '' - startLine: 5407 + startLine: 5409 assemblies: - cs.temp.dll namespace: Rssdp @@ -135,7 +135,7 @@ items: source: id: Namespace path: '' - startLine: 5417 + startLine: 5419 assemblies: - cs.temp.dll namespace: Rssdp @@ -168,7 +168,7 @@ items: source: id: Name path: '' - startLine: 5422 + startLine: 5424 assemblies: - cs.temp.dll namespace: Rssdp @@ -201,7 +201,7 @@ items: source: id: FullName path: '' - startLine: 5427 + startLine: 5429 assemblies: - cs.temp.dll namespace: Rssdp @@ -234,7 +234,7 @@ items: source: id: Value path: '' - startLine: 5432 + startLine: 5434 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpDevicePublisher.yml b/src/Main/Lib/api/Rssdp.SsdpDevicePublisher.yml index 7da4ad5..9295792 100644 --- a/src/Main/Lib/api/Rssdp.SsdpDevicePublisher.yml +++ b/src/Main/Lib/api/Rssdp.SsdpDevicePublisher.yml @@ -21,7 +21,7 @@ items: source: id: SsdpDevicePublisher path: '' - startLine: 5448 + startLine: 5450 assemblies: - cs.temp.dll namespace: Rssdp @@ -81,7 +81,7 @@ items: source: id: .ctor path: '' - startLine: 5459 + startLine: 5461 assemblies: - cs.temp.dll namespace: Rssdp @@ -110,7 +110,7 @@ items: source: id: .ctor path: '' - startLine: 5472 + startLine: 5474 assemblies: - cs.temp.dll namespace: Rssdp @@ -142,7 +142,7 @@ items: source: id: .ctor path: '' - startLine: 5484 + startLine: 5486 assemblies: - cs.temp.dll namespace: Rssdp @@ -176,7 +176,7 @@ items: source: id: .ctor path: '' - startLine: 5497 + startLine: 5499 assemblies: - cs.temp.dll namespace: Rssdp @@ -209,7 +209,7 @@ items: source: id: .ctor path: '' - startLine: 5509 + startLine: 5511 assemblies: - cs.temp.dll namespace: Rssdp @@ -241,7 +241,7 @@ items: source: id: .ctor path: '' - startLine: 5526 + startLine: 5528 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpEmbeddedDevice.yml b/src/Main/Lib/api/Rssdp.SsdpEmbeddedDevice.yml index 528bfaa..1aa9195 100644 --- a/src/Main/Lib/api/Rssdp.SsdpEmbeddedDevice.yml +++ b/src/Main/Lib/api/Rssdp.SsdpEmbeddedDevice.yml @@ -18,7 +18,7 @@ items: source: id: SsdpEmbeddedDevice path: '' - startLine: 6961 + startLine: 6963 assemblies: - cs.temp.dll namespace: Rssdp @@ -96,7 +96,7 @@ items: source: id: .ctor path: '' - startLine: 6975 + startLine: 6977 assemblies: - cs.temp.dll namespace: Rssdp @@ -124,7 +124,7 @@ items: source: id: .ctor path: '' - startLine: 6986 + startLine: 6988 assemblies: - cs.temp.dll namespace: Rssdp @@ -166,7 +166,7 @@ items: source: id: RootDevice path: '' - startLine: 6998 + startLine: 7000 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpRootDevice.yml b/src/Main/Lib/api/Rssdp.SsdpRootDevice.yml index d7bf559..8730a47 100644 --- a/src/Main/Lib/api/Rssdp.SsdpRootDevice.yml +++ b/src/Main/Lib/api/Rssdp.SsdpRootDevice.yml @@ -22,7 +22,7 @@ items: source: id: SsdpRootDevice path: '' - startLine: 7035 + startLine: 7037 assemblies: - cs.temp.dll namespace: Rssdp @@ -101,7 +101,7 @@ items: source: id: .ctor path: '' - startLine: 7063 + startLine: 7065 assemblies: - cs.temp.dll namespace: Rssdp @@ -129,7 +129,7 @@ items: source: id: .ctor path: '' - startLine: 7075 + startLine: 7077 assemblies: - cs.temp.dll namespace: Rssdp @@ -174,7 +174,7 @@ items: source: id: .ctor path: '' - startLine: 7089 + startLine: 7091 assemblies: - cs.temp.dll namespace: Rssdp @@ -225,7 +225,7 @@ items: source: id: CacheLifetime path: '' - startLine: 7112 + startLine: 7114 assemblies: - cs.temp.dll namespace: Rssdp @@ -259,7 +259,7 @@ items: source: id: Location path: '' - startLine: 7120 + startLine: 7122 assemblies: - cs.temp.dll namespace: Rssdp @@ -292,7 +292,7 @@ items: source: id: UrlBase path: '' - startLine: 7129 + startLine: 7131 assemblies: - cs.temp.dll namespace: Rssdp @@ -326,7 +326,7 @@ items: source: id: ToDescriptionDocument path: '' - startLine: 7150 + startLine: 7152 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpService.yml b/src/Main/Lib/api/Rssdp.SsdpService.yml index 3583386..4cdc199 100644 --- a/src/Main/Lib/api/Rssdp.SsdpService.yml +++ b/src/Main/Lib/api/Rssdp.SsdpService.yml @@ -27,7 +27,7 @@ items: source: id: SsdpService path: '' - startLine: 7239 + startLine: 7241 assemblies: - cs.temp.dll namespace: Rssdp @@ -66,7 +66,7 @@ items: source: id: .ctor path: '' - startLine: 7247 + startLine: 7249 assemblies: - cs.temp.dll namespace: Rssdp @@ -94,7 +94,7 @@ items: source: id: .ctor path: '' - startLine: 7260 + startLine: 7262 assemblies: - cs.temp.dll namespace: Rssdp @@ -134,7 +134,7 @@ items: source: id: ServiceType path: '' - startLine: 7283 + startLine: 7285 assemblies: - cs.temp.dll namespace: Rssdp @@ -174,7 +174,7 @@ items: source: id: ServiceTypeNamespace path: '' - startLine: 7291 + startLine: 7293 assemblies: - cs.temp.dll namespace: Rssdp @@ -214,7 +214,7 @@ items: source: id: ServiceVersion path: '' - startLine: 7300 + startLine: 7302 assemblies: - cs.temp.dll namespace: Rssdp @@ -255,7 +255,7 @@ items: source: id: FullServiceType path: '' - startLine: 7308 + startLine: 7310 assemblies: - cs.temp.dll namespace: Rssdp @@ -289,7 +289,7 @@ items: source: id: Uuid path: '' - startLine: 7328 + startLine: 7330 assemblies: - cs.temp.dll namespace: Rssdp @@ -323,7 +323,7 @@ items: source: id: ServiceId path: '' - startLine: 7336 + startLine: 7338 assemblies: - cs.temp.dll namespace: Rssdp @@ -357,7 +357,7 @@ items: source: id: ScpdUrl path: '' - startLine: 7354 + startLine: 7356 assemblies: - cs.temp.dll namespace: Rssdp @@ -390,7 +390,7 @@ items: source: id: ControlUrl path: '' - startLine: 7358 + startLine: 7360 assemblies: - cs.temp.dll namespace: Rssdp @@ -423,7 +423,7 @@ items: source: id: EventSubUrl path: '' - startLine: 7362 + startLine: 7364 assemblies: - cs.temp.dll namespace: Rssdp @@ -456,7 +456,7 @@ items: source: id: WriteServiceDescriptionXml path: '' - startLine: 7373 + startLine: 7375 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpStandardsMode.yml b/src/Main/Lib/api/Rssdp.SsdpStandardsMode.yml index f295830..9d00037 100644 --- a/src/Main/Lib/api/Rssdp.SsdpStandardsMode.yml +++ b/src/Main/Lib/api/Rssdp.SsdpStandardsMode.yml @@ -18,7 +18,7 @@ items: source: id: SsdpStandardsMode path: '' - startLine: 7528 + startLine: 7530 assemblies: - cs.temp.dll namespace: Rssdp @@ -47,7 +47,7 @@ items: source: id: Default path: '' - startLine: 7533 + startLine: 7535 assemblies: - cs.temp.dll namespace: Rssdp @@ -77,7 +77,7 @@ items: source: id: Relaxed path: '' - startLine: 7540 + startLine: 7542 assemblies: - cs.temp.dll namespace: Rssdp @@ -108,7 +108,7 @@ items: source: id: Strict path: '' - startLine: 7544 + startLine: 7546 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Lib/api/Rssdp.SsdpTraceLogger.yml b/src/Main/Lib/api/Rssdp.SsdpTraceLogger.yml index a8f5a9e..5e29ee6 100644 --- a/src/Main/Lib/api/Rssdp.SsdpTraceLogger.yml +++ b/src/Main/Lib/api/Rssdp.SsdpTraceLogger.yml @@ -19,7 +19,7 @@ items: source: id: SsdpTraceLogger path: '' - startLine: 7558 + startLine: 7560 assemblies: - cs.temp.dll namespace: Rssdp @@ -63,7 +63,7 @@ items: source: id: LogInfo path: '' - startLine: 7564 + startLine: 7566 assemblies: - cs.temp.dll namespace: Rssdp @@ -97,7 +97,7 @@ items: source: id: LogVerbose path: '' - startLine: 7573 + startLine: 7575 assemblies: - cs.temp.dll namespace: Rssdp @@ -131,7 +131,7 @@ items: source: id: LogWarning path: '' - startLine: 7582 + startLine: 7584 assemblies: - cs.temp.dll namespace: Rssdp @@ -165,7 +165,7 @@ items: source: id: LogError path: '' - startLine: 7591 + startLine: 7593 assemblies: - cs.temp.dll namespace: Rssdp diff --git a/src/Main/Test.Rssdp/CommServerTests.cs b/src/Main/Test.Rssdp/CommServerTests.cs index 7d5303d..7f345be 100644 --- a/src/Main/Test.Rssdp/CommServerTests.cs +++ b/src/Main/Test.Rssdp/CommServerTests.cs @@ -41,41 +41,51 @@ public void CommsServer_FullConstructor_SpecifiedPortUsedForUnicastSocket() Assert.AreEqual(1702, mockSocket.LocalPort); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void CommsServer_MinimumConstructor_NullSocketFactoryThrowsExeption() { - _ = new SsdpCommunicationsServer(null); + Assert.Throws(() => + { + _ = new SsdpCommunicationsServer(null); + }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void CommsServer_FactoryAndSocketConstructor_NullSocketFactoryThrowsExeption() { - _ = new SsdpCommunicationsServer(null, 1701); + Assert.Throws(() => + { + _ = new SsdpCommunicationsServer(null, 1701); + }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void CommsServer_FullConstructor_NullSocketFactoryThrowsExeption() { - _ = new SsdpCommunicationsServer(null, 1701, 4); + Assert.Throws(() => + { + _ = new SsdpCommunicationsServer(null, 1701, 4); + }); } - [ExpectedException(typeof(System.ArgumentOutOfRangeException))] [TestMethod] public void CommsServer_FullConstructor_NegativeMulticastTtlThrowsException() { var socketFactory = new MockSocketFactory(); - _ = new SsdpCommunicationsServer(socketFactory, 1701, -1); + Assert.Throws(() => + { + _ = new SsdpCommunicationsServer(socketFactory, 1701, -1); + }); } - [ExpectedException(typeof(System.ArgumentOutOfRangeException))] [TestMethod] public void CommsServer_FullConstructor_ZeroMulticastTtlThrowsException() { var socketFactory = new MockSocketFactory(); - _ = new SsdpCommunicationsServer(socketFactory, 1701, 0); + Assert.Throws(() => + { + _ = new SsdpCommunicationsServer(socketFactory, 1701, 0); + }); } [TestMethod] @@ -165,7 +175,6 @@ some content here } } - [ExpectedException(typeof(System.ObjectDisposedException))] [TestMethod] public void CommsServer_BeginListeningForBroadcastsThrowsIfDisposed() { @@ -173,10 +182,12 @@ public void CommsServer_BeginListeningForBroadcastsThrowsIfDisposed() var server = new SsdpCommunicationsServer(socketFactory); server.Dispose(); - server.BeginListeningForBroadcasts(); + Assert.Throws(() => + { + server.BeginListeningForBroadcasts(); + }); } - [ExpectedException(typeof(System.ObjectDisposedException))] [TestMethod] public void CommsServer_StopListeningForBroadcastsThrowsIfDisposed() { @@ -184,10 +195,12 @@ public void CommsServer_StopListeningForBroadcastsThrowsIfDisposed() var server = new SsdpCommunicationsServer(socketFactory); server.Dispose(); - server.StopListeningForBroadcasts(); + Assert.Throws(() => + { + server.StopListeningForBroadcasts(); + }); } - [ExpectedException(typeof(System.ObjectDisposedException))] [TestMethod] public void CommsServer_StopListeningForResponsesThrowsIfDisposed() { @@ -195,7 +208,10 @@ public void CommsServer_StopListeningForResponsesThrowsIfDisposed() var server = new SsdpCommunicationsServer(socketFactory); server.Dispose(); - server.StopListeningForResponses(); + Assert.Throws(() => + { + server.StopListeningForResponses(); + }); } [TestMethod] @@ -294,15 +310,20 @@ public void CommsServer_SendMessageSendsOnUnicastSocket() Assert.AreEqual(destination.Port, mockSocket.LastSentTo.Port); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void CommsServer_SendNullMessageThrowsException() { var socketFactory = new MockSocketFactory(); var server = new SsdpCommunicationsServer(socketFactory); - UdpEndPoint destination = new UdpEndPoint("192.168.1.100", 1701); - server.SendMessage(null, destination); + + Assert.Throws + ( + () => + { + server.SendMessage(null, destination); + } + ); } [TestMethod] @@ -654,7 +675,7 @@ some content here var mockSocket = socketFactory.MulticastSocket as MockSocket; mockSocket.MockReceive(System.Text.UTF8Encoding.UTF8.GetBytes(message), SsdpConstants.MulticastLocalAdminEndpoint); - eventReceivedSignal.WaitOne(10000); + eventReceivedSignal.WaitOne(30000); Assert.IsTrue(requestReceived); Assert.IsFalse(responseReceived); Assert.AreEqual("UTF8", receivedMessage.Content.Headers.ContentEncoding.FirstOrDefault()); diff --git a/src/Main/Test.Rssdp/CustomHttpHeaderTests.cs b/src/Main/Test.Rssdp/CustomHttpHeaderTests.cs index de06aaa..2431969 100644 --- a/src/Main/Test.Rssdp/CustomHttpHeaderTests.cs +++ b/src/Main/Test.Rssdp/CustomHttpHeaderTests.cs @@ -35,43 +35,53 @@ public void CustomHttpHeader_CanCreateWithNullValue() { var header = new CustomHttpHeader("X-TestName", null); Assert.AreEqual("X-TestName", header.Name); - Assert.AreEqual(null, header.Value); + Assert.IsNull(header.Value); Assert.AreEqual("X-TestName: ", header.ToString()); } [TestMethod()] - [ExpectedException(typeof(System.ArgumentNullException))] public void CustomHttpHeader_ThrowsOnNullName() { - var header = new CustomHttpHeader(null, "Test Value"); + Assert.Throws(() => + { + _ = new CustomHttpHeader(null, "Test Value"); + }); } [TestMethod()] - [ExpectedException(typeof(System.ArgumentException))] public void CustomHttpHeader_ThrowsOnEmptyName() { - var header = new CustomHttpHeader(String.Empty, "Test Value"); + Assert.Throws(() => + { + _ = new CustomHttpHeader(String.Empty, "Test Value"); + }); } [TestMethod()] - [ExpectedException(typeof(System.ArgumentException))] public void CustomHttpHeader_ThrowsOnValueWithLineFeed() { - var header = new CustomHttpHeader("X-TestName", "Test\nValue"); + Assert.Throws(() => + { + _ = new CustomHttpHeader("X-TestName", "Test\nValue"); + }); } [TestMethod()] - [ExpectedException(typeof(System.ArgumentException))] public void CustomHttpHeader_ThrowsOnValueWithCarriageReturnFeed() { - var header = new CustomHttpHeader("X-TestName", "Test\rValue"); + Assert.Throws(() => + { + _ = new CustomHttpHeader("X-TestName", "Test\r\nValue"); + }); } [TestMethod()] - [ExpectedException(typeof(System.ArgumentException))] public void CustomHttpHeader_ThrowsOnNameWithColonFeed() { - var header = new CustomHttpHeader("X:TestName", "Test Value"); + Assert.Throws(() => + { + _ = new CustomHttpHeader("X:TestName", "Test Value"); + }); } } diff --git a/src/Main/Test.Rssdp/CustomHttpHeadersCollectionTests.cs b/src/Main/Test.Rssdp/CustomHttpHeadersCollectionTests.cs index a061b59..e0876e7 100644 --- a/src/Main/Test.Rssdp/CustomHttpHeadersCollectionTests.cs +++ b/src/Main/Test.Rssdp/CustomHttpHeadersCollectionTests.cs @@ -18,20 +18,22 @@ public class CustomHttpHeadersCollectionTests [TestMethod] public void CustomHttpHeadersCollection_CapacityConstructor_Succeeds() { - var properties = new CustomHttpHeadersCollection(10); + _ = new CustomHttpHeadersCollection(10); } [TestMethod] public void CustomHttpHeadersCollection_CapacityConstructor_SucceedsWithZeroValue() { - var properties = new CustomHttpHeadersCollection(0); + _ = new CustomHttpHeadersCollection(0); } [TestMethod] - [ExpectedException(typeof(System.ArgumentOutOfRangeException))] public void CustomHttpHeadersCollection_CapacityConstructor_FailsWithNegativeValue() { - var properties = new CustomHttpHeadersCollection(-1); + Assert.Throws(() => + { + _ = new CustomHttpHeadersCollection(-1); + }); } #endregion @@ -39,12 +41,14 @@ public void CustomHttpHeadersCollection_CapacityConstructor_FailsWithNegativeVal #region Add Tests [TestMethod] - [ExpectedException(typeof(System.ArgumentNullException))] public void CustomHttpHeadersCollection_Add_NullThrows() { var properties = new CustomHttpHeadersCollection(); - properties.Add(null); + Assert.Throws(() => + { + properties.Add((CustomHttpHeader)null); + }); } #endregion @@ -52,30 +56,36 @@ public void CustomHttpHeadersCollection_Add_NullThrows() #region Remove Tests [TestMethod] - [ExpectedException(typeof(System.ArgumentNullException))] public void CustomHttpHeadersCollection_Remove_NullThrows() { var properties = new CustomHttpHeadersCollection(); - properties.Remove((CustomHttpHeader)null); + Assert.Throws(() => + { + properties.Remove((CustomHttpHeader)null); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void CustomHttpHeadersCollection_Remove_NullKeyThrows() { var properties = new CustomHttpHeadersCollection(); - properties.Remove((string)null); + Assert.Throws(() => + { + properties.Remove((string)null); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void CustomHttpHeadersCollection_Remove_EmptyKeyThrows() { var properties = new CustomHttpHeadersCollection(); - properties.Remove(String.Empty); + Assert.Throws(() => + { + properties.Remove(String.Empty); + }); } [TestMethod] @@ -86,7 +96,7 @@ public void CustomHttpHeadersCollection_Remove_RemoveInstanceSucceeds() properties.Add(p); - Assert.AreEqual(true, properties.Remove(p)); + Assert.IsTrue(properties.Remove(p)); Assert.AreEqual(0, properties.Count); } @@ -100,7 +110,7 @@ public void CustomHttpHeadersCollection_Remove_RemoveInstanceForDifferentInstanc properties.Add(p); - Assert.AreEqual(false, properties.Remove(p2)); + Assert.IsFalse(properties.Remove(p2)); Assert.AreEqual(1, properties.Count); } @@ -112,7 +122,7 @@ public void CustomHttpHeadersCollection_Remove_RemoveByKeySucceeds() properties.Add(p); - Assert.AreEqual(true, properties.Remove(p.Name)); + Assert.IsTrue(properties.Remove(p.Name)); Assert.AreEqual(0, properties.Count); } @@ -121,27 +131,35 @@ public void CustomHttpHeadersCollection_Remove_RemoveByKeySucceeds() #region Contains Tests [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void CustomHttpHeadersCollection_Contains_NullNameThrows() { var properties = new CustomHttpHeadersCollection(); - properties.Contains((string)null); + + Assert.Throws(() => + { + properties.Contains((string)null); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void CustomHttpHeadersCollection_Contains_EmptyNameThrows() { var properties = new CustomHttpHeadersCollection(); - properties.Contains(String.Empty); + + Assert.Throws(() => + { + properties.Contains(String.Empty); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentNullException))] public void CustomHttpHeadersCollection_Contains_NullPropertyThrows() { var properties = new CustomHttpHeadersCollection(); - properties.Contains((CustomHttpHeader)null); + Assert.Throws(() => + { + _ = properties.Contains((CustomHttpHeader)null); + }); } [TestMethod] @@ -152,7 +170,7 @@ public void CustomHttpHeadersCollection_Contains_ReturnsTrueForExistingKey() properties.Add(prop); - Assert.AreEqual(true, properties.Contains(prop.Name)); + Assert.IsTrue(properties.Contains(prop.Name)); } [TestMethod] @@ -163,7 +181,7 @@ public void CustomHttpHeadersCollection_Contains_ReturnsFalseForNonExistentKey() properties.Add(prop); - Assert.AreEqual(false, properties.Contains("NotAValidKey")); + Assert.IsFalse(properties.Contains("NotAValidKey")); } [TestMethod] @@ -174,7 +192,7 @@ public void CustomHttpHeadersCollection_Contains_ReturnsTrueForExistingItem() properties.Add(prop); - Assert.AreEqual(true, properties.Contains(prop)); + Assert.IsTrue(properties.Contains(prop)); } [TestMethod] @@ -187,7 +205,7 @@ public void CustomHttpHeadersCollection_Contains_ReturnsFalseForExistingKeyDiffe properties.Add(prop); - Assert.AreEqual(false, properties.Contains(prop2)); + Assert.IsFalse(properties.Contains(prop2)); } [TestMethod] @@ -200,7 +218,7 @@ public void CustomHttpHeadersCollection_Contains_ReturnsFalseForNonExistentPrope properties.Add(prop); - Assert.AreEqual(false, properties.Contains(prop2)); + Assert.IsFalse(properties.Contains(prop2)); } #endregion @@ -216,9 +234,9 @@ public void CustomHttpHeadersCollection_GenericGetEnumerator_Success() properties.Add(prop); var enumerator = properties.GetEnumerator(); - Assert.AreEqual(true, enumerator.MoveNext()); + Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual(prop, enumerator.Current); - Assert.AreEqual(false, enumerator.MoveNext()); + Assert.IsFalse(enumerator.MoveNext()); } [TestMethod] @@ -230,9 +248,9 @@ public void CustomHttpHeadersCollection_GetEnumerator_Success() properties.Add(prop); var enumerator = ((IEnumerable)properties).GetEnumerator(); - Assert.AreEqual(true, enumerator.MoveNext()); + Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual(prop, enumerator.Current); - Assert.AreEqual(false, enumerator.MoveNext()); + Assert.IsFalse(enumerator.MoveNext()); } #endregion @@ -250,7 +268,6 @@ public void CustomHttpHeadersCollection_Indexer_Succeeds() Assert.AreEqual(p, properties[p.Name]); } - [ExpectedException(typeof(System.Collections.Generic.KeyNotFoundException))] [TestMethod] public void CustomHttpHeadersCollection_Indexer_ThrowsOnUnknownKey() { @@ -259,7 +276,10 @@ public void CustomHttpHeadersCollection_Indexer_ThrowsOnUnknownKey() properties.Add(p); - Assert.AreEqual(p, properties["NotAValidKey"]); + Assert.Throws(() => + { + _ = properties["NotAValidKey"]; + }); } #endregion diff --git a/src/Main/Test.Rssdp/DeviceDeserialisationTests.cs b/src/Main/Test.Rssdp/DeviceDeserialisationTests.cs index 6f2b758..7bb3a59 100644 --- a/src/Main/Test.Rssdp/DeviceDeserialisationTests.cs +++ b/src/Main/Test.Rssdp/DeviceDeserialisationTests.cs @@ -201,42 +201,52 @@ public void ToDescriptionDocument_DeserialisesEmptyUrlNodesSuccessfully() modelUrlNode.Value = String.Empty; var deserialisedDevice = new SsdpRootDevice(rootDevice.Location, rootDevice.CacheLifetime, doc.ToString()); - Assert.AreEqual(null, deserialisedDevice.ModelUrl); + Assert.IsNull(deserialisedDevice.ModelUrl); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void DeserialisationConstructor_ThrowsOnNullDocument() { - _ = new SsdpEmbeddedDevice(null, new System.Xml.XmlReaderSettings()); + Assert.Throws(() => + { + _ = new SsdpEmbeddedDevice(null, new System.Xml.XmlReaderSettings()); + }); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void DeserialisationConstructor_ThrowsOnEmptyDocument() { - _ = new SsdpEmbeddedDevice(String.Empty, new System.Xml.XmlReaderSettings()); + Assert.Throws(() => + { + _ = new SsdpEmbeddedDevice(String.Empty, new System.Xml.XmlReaderSettings()); + }); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void RootDeviceDeserialisationConstructor_ThrowsOnEmptyDocument() { - _ = new SsdpRootDevice(new Uri("http://somedevice:1700"), TimeSpan.FromMinutes(30), String.Empty); + Assert.Throws(() => + { + _ = new SsdpRootDevice(new Uri("http://somedevice:1700"), TimeSpan.FromMinutes(30), String.Empty); + }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void RootDeviceDeserialisationConstructor_ThrowsOnNullDocument() { - _ = new SsdpRootDevice(new Uri("http://somedevice:1700"), TimeSpan.FromMinutes(30), null); + Assert.Throws(() => + { + _ = new SsdpRootDevice(new Uri("http://somedevice:1700"), TimeSpan.FromMinutes(30), null); + }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void RootDeviceDeserialisationConstructor_ThrowsOnLocation() { - _ = new SsdpRootDevice(null, TimeSpan.FromMinutes(30), ""); + Assert.Throws(() => + { + _ = new SsdpRootDevice(null, TimeSpan.FromMinutes(30), null); + }); } private void AssertDevicesAreSame(SsdpRootDevice originalDevice, SsdpRootDevice deserialisedDevice) diff --git a/src/Main/Test.Rssdp/DeviceLocatorTests.cs b/src/Main/Test.Rssdp/DeviceLocatorTests.cs index 69c3a54..617648c 100644 --- a/src/Main/Test.Rssdp/DeviceLocatorTests.cs +++ b/src/Main/Test.Rssdp/DeviceLocatorTests.cs @@ -16,25 +16,29 @@ public class DeviceLocatorTests #region Constructor Tests - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod()] public void DeviceLocator_Constructor_ThrowsOnNullCommsServer() { - _ = new MockDeviceLocator(null); + Assert.Throws(() => + { + _ = new MockDeviceLocator(null); + }); } #endregion #region Notifications Tests - [ExpectedException(typeof(System.ObjectDisposedException))] [TestMethod()] public void DeviceLocator_Notifications_StartListeningThrowsIfDisposed() { var deviceLocator = new MockDeviceLocator(); deviceLocator.Dispose(); - deviceLocator.StartListeningForNotifications(); + Assert.Throws(() => + { + deviceLocator.StartListeningForNotifications(); + }); } [TestMethod()] @@ -205,14 +209,16 @@ public void DeviceLocator_Notifications_StopListeningNoLongerReceivesNotificatio Assert.IsFalse(receivedNotification); } - [ExpectedException(typeof(System.ObjectDisposedException))] [TestMethod()] public void DeviceLocator_Notifications_Notifications_StopListeningThrowsIfDisposed() { var deviceLocator = new MockDeviceLocator(); deviceLocator.Dispose(); - deviceLocator.StopListeningForNotifications(); + Assert.Throws(() => + { + deviceLocator.StopListeningForNotifications(); + }); } [TestMethod()] @@ -425,7 +431,7 @@ public void DeviceLocator_Notifications_SubsequentNotificationsUpdatesCachedDesc server.MockReceiveBroadcast(GetMockAliveNotification(publishedDevice)); signal.WaitOne(10000); - var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(5)); + var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(5), TestContext.CancellationToken); var updatedDevice = CreateDeviceTree(); updatedDevice.Uuid = publishedDevice.Uuid; @@ -474,7 +480,7 @@ public void DeviceLocator_Notifications_ContainHeaders() Assert.IsTrue(discoveredDevices.Any()); Assert.IsNotNull(first.ResponseHeaders); - Assert.AreEqual(first.ResponseHeaders.GetValues("NTS").FirstOrDefault(), "ssdp:alive"); + Assert.AreEqual("ssdp:alive", first.ResponseHeaders.GetValues("NTS").FirstOrDefault()); } } @@ -499,7 +505,7 @@ public void DeviceLocator_Notifications_SubsequentNotificationsUpdatesCachedCach server.MockReceiveBroadcast(GetMockAliveNotification(publishedDevice)); signal.WaitOne(10000); - var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(5)); + var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(5), TestContext.CancellationToken); var updatedDevice = CreateDeviceTree(); updatedDevice.Uuid = publishedDevice.Uuid; @@ -539,20 +545,20 @@ public void DeviceLocator_SearchAsync_HandlesConcurrentDispose() deviceLocator.Dispose(); }); - var t = deviceLocator.SearchAsync(); + var t = deviceLocator.SearchAsync(TestContext.CancellationToken); AggregateException exception = null; try { - t.Wait(); + t.Wait(TestContext.CancellationToken); } catch (AggregateException aex) { exception = aex; } - Assert.AreNotEqual(null, exception); - Assert.AreEqual(1, exception.InnerExceptions.Count); + Assert.IsNotNull(exception); + Assert.HasCount(1, exception.InnerExceptions); Assert.AreEqual(typeof(System.ObjectDisposedException), exception.InnerExceptions.First().GetType()); } } @@ -563,8 +569,8 @@ public void DeviceLocator_SearchAsync_SearchesForAllDevices() var server = new MockCommsServer(); var deviceLocator = new MockDeviceLocator(server); - var t = deviceLocator.SearchAsync(); - t.Wait(); + var t = deviceLocator.SearchAsync(TestContext.CancellationToken); + t.Wait(TestContext.CancellationToken); Assert.IsTrue(server.SentBroadcasts.Any()); var searchRequestData = server.SentBroadcasts.First(); @@ -583,8 +589,8 @@ public void DeviceLocator_SearchAsync_SearchesForSpecifiedTarget() var deviceLocator = new MockDeviceLocator(server); var searchTarget = "uuid:" + Guid.NewGuid().ToString(); - var t = deviceLocator.SearchAsync(searchTarget); - t.Wait(); + var t = deviceLocator.SearchAsync(searchTarget, TestContext.CancellationToken); + t.Wait(TestContext.CancellationToken); Assert.IsTrue(server.SentBroadcasts.Any()); var searchRequestData = server.SentBroadcasts.First(); @@ -603,8 +609,8 @@ public void DeviceLocator_SearchAsync_UsesSpecifiedSearchTimeLess1Second() var deviceLocator = new MockDeviceLocator(server); var searchTime = TimeSpan.FromSeconds(2); - var t = deviceLocator.SearchAsync(searchTime); - t.Wait(); + var t = deviceLocator.SearchAsync(searchTime, TestContext.CancellationToken); + t.Wait(TestContext.CancellationToken); Assert.IsTrue(server.SentBroadcasts.Any()); var searchRequestData = server.SentBroadcasts.First(); @@ -616,7 +622,6 @@ public void DeviceLocator_SearchAsync_UsesSpecifiedSearchTimeLess1Second() Assert.AreEqual((searchTime.TotalSeconds - 1).ToString(), GetFirstHeaderValue(searchRequest, "MX")); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void DeviceLocator_SearchAsync_ThrowsIfSearchTime1Second() { @@ -624,11 +629,14 @@ public void DeviceLocator_SearchAsync_ThrowsIfSearchTime1Second() var deviceLocator = new MockDeviceLocator(server); var searchTime = TimeSpan.FromSeconds(1); - var t = deviceLocator.SearchAsync(searchTime); - t.GetAwaiter().GetResult(); + var t = deviceLocator.SearchAsync(searchTime, TestContext.CancellationToken); + + Assert.Throws(() => + { + t.GetAwaiter().GetResult(); + }); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void DeviceLocator_SearchAsync_ThrowsIfSearchTimeLessThan1Second() { @@ -636,11 +644,14 @@ public void DeviceLocator_SearchAsync_ThrowsIfSearchTimeLessThan1Second() var deviceLocator = new MockDeviceLocator(server); var searchTime = TimeSpan.FromMilliseconds(500); - var t = deviceLocator.SearchAsync(searchTime); - t.GetAwaiter().GetResult(); + var t = deviceLocator.SearchAsync(searchTime, TestContext.CancellationToken); + + Assert.Throws(() => + { + t.GetAwaiter().GetResult(); + }); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void DeviceLocator_SearchAsync_ThrowsIfSearchTimeNegative() { @@ -648,11 +659,14 @@ public void DeviceLocator_SearchAsync_ThrowsIfSearchTimeNegative() var deviceLocator = new MockDeviceLocator(server); var searchTime = TimeSpan.FromSeconds(-5); - var t = deviceLocator.SearchAsync(searchTime); - t.GetAwaiter().GetResult(); + var t = deviceLocator.SearchAsync(searchTime, TestContext.CancellationToken); + + Assert.Throws(() => + { + t.GetAwaiter().GetResult(); + }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void DeviceLocator_SearchAsync_ThrowsIfSearchTargetNull() { @@ -660,11 +674,14 @@ public void DeviceLocator_SearchAsync_ThrowsIfSearchTargetNull() var deviceLocator = new MockDeviceLocator(server); string searchTarget = null; - var t = deviceLocator.SearchAsync(searchTarget); - t.GetAwaiter().GetResult(); + var t = deviceLocator.SearchAsync(searchTarget, TestContext.CancellationToken); + + Assert.Throws(() => + { + t.GetAwaiter().GetResult(); + }); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void DeviceLocator_SearchAsync_ThrowsIfSearchTargetEmpty() { @@ -672,8 +689,12 @@ public void DeviceLocator_SearchAsync_ThrowsIfSearchTargetEmpty() var deviceLocator = new MockDeviceLocator(server); string searchTarget = String.Empty; - var t = deviceLocator.SearchAsync(searchTarget); - t.GetAwaiter().GetResult(); + var t = deviceLocator.SearchAsync(searchTarget, TestContext.CancellationToken); + + Assert.Throws(() => + { + t.GetAwaiter().GetResult(); + }); } [TestMethod] @@ -683,13 +704,12 @@ public void DeviceLocator_SearchAsync_AllowsZeroSearchTime() var deviceLocator = new MockDeviceLocator(server); string searchTarget = "ssdp:all"; - var t = deviceLocator.SearchAsync(searchTarget, TimeSpan.Zero); + var t = deviceLocator.SearchAsync(searchTarget, TimeSpan.Zero, TestContext.CancellationToken); t.GetAwaiter().GetResult(); server.Dispose(); deviceLocator.Dispose(); } - [ExpectedException(typeof(System.InvalidOperationException))] [TestMethod] public void DeviceLocator_SearchAsync_ThrowsOnDuplicateConcurrentSearch() { @@ -697,9 +717,12 @@ public void DeviceLocator_SearchAsync_ThrowsOnDuplicateConcurrentSearch() var deviceLocator = new MockDeviceLocator(server); string searchTarget = "ssdp:all"; - var t = deviceLocator.SearchAsync(searchTarget, TimeSpan.FromSeconds(10)); - var t2 = deviceLocator.SearchAsync(searchTarget, TimeSpan.FromSeconds(1.5)); - t2.GetAwaiter().GetResult(); + var t = deviceLocator.SearchAsync(searchTarget, TimeSpan.FromSeconds(10), TestContext.CancellationToken); + var t2 = deviceLocator.SearchAsync(searchTarget, TimeSpan.FromSeconds(1.5), TestContext.CancellationToken); + Assert.Throws(() => + { + t2.GetAwaiter().GetResult(); + }); t.GetAwaiter().GetResult(); } @@ -728,10 +751,10 @@ public void DeviceLocator_SearchAsync_ReturnsCachedDevices() eventSignal.WaitOne(10000); Assert.IsTrue(receivedNotification); - var results = deviceLocator.SearchAsync(TimeSpan.Zero).GetAwaiter().GetResult(); + var results = deviceLocator.SearchAsync(TimeSpan.Zero, TestContext.CancellationToken).GetAwaiter().GetResult(); Assert.IsNotNull(results); Assert.IsTrue(results.Any()); - Assert.IsTrue(results.First().Usn == device.Usn); + Assert.AreEqual(device.Usn, results.First().Usn); } } @@ -744,16 +767,16 @@ public async Task DeviceLocator_SearchAsync_AllowsCancellation() var sw = new Stopwatch(); sw.Start(); var cts = new System.Threading.CancellationTokenSource(); - _ = Task.Delay(1000).ContinueWith((pt) => cts.Cancel()); + _ = Task.Delay(1000, TestContext.CancellationToken).ContinueWith((pt) => cts.Cancel(), TestContext.CancellationToken); - await Assert.ThrowsExceptionAsync(async () => + await Assert.ThrowsAsync(async () => { await deviceLocator.SearchAsync(TimeSpan.FromSeconds(60), cts.Token); }); sw.Stop(); - Assert.IsTrue(sw.Elapsed.TotalSeconds < 5); + Assert.IsLessThan(5, sw.Elapsed.TotalSeconds); } [TestMethod()] @@ -777,7 +800,7 @@ public void DeviceLocator_Notifications_HandlesByeByeDuringSearch() server.MockReceiveBroadcast(GetMockAliveNotification()); server.WaitForMessageToProcess(10000); - var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3)); + var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3), TestContext.CancellationToken); System.Threading.Thread.Sleep(500); server.MockReceiveBroadcast(GetMockByeByeNotification()); eventSignal.WaitOne(10000); @@ -810,7 +833,7 @@ public void DeviceLocator_Notifications_ProcessesSearchResponse() eventSignal.Set(); }; - var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3)); + var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3), TestContext.CancellationToken); System.Threading.Thread.Sleep(500); server.MockReceiveMessage(GetMockSearchResponse(publishedDevice, publishedDevice.Udn)); eventSignal.WaitOne(10000); @@ -844,7 +867,7 @@ public void DeviceLocator_Notifications_RetrievesCustomHeader() eventSignal.Set(); }; - var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3)); + var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3), TestContext.CancellationToken); System.Threading.Thread.Sleep(500); server.MockReceiveMessage(GetMockSearchResponse(publishedDevice, publishedDevice.Udn)); eventSignal.WaitOne(10000); @@ -884,7 +907,7 @@ public void DeviceLocator_Notifications_SearchResponseMissingCacheHeaderIsNonCac eventSignal.Set(); }; - var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3)); + var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3), TestContext.CancellationToken); System.Threading.Thread.Sleep(500); server.MockReceiveMessage(GetMockSearchResponseWithCustomCacheHeader(publishedDevice, publishedDevice.Udn, null)); eventSignal.WaitOne(10000); @@ -918,7 +941,7 @@ public void DeviceLocator_Notifications_SearchResponseUsesSharedMaxAge() eventSignal.Set(); }; - var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3)); + var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3), TestContext.CancellationToken); System.Threading.Thread.Sleep(500); server.MockReceiveMessage(GetMockSearchResponseWithCustomCacheHeader(publishedDevice, publishedDevice.Udn, String.Format("CACHE-CONTROL: public, s-maxage={0}", publishedDevice.CacheLifetime.TotalSeconds))); eventSignal.WaitOne(10000); @@ -949,7 +972,7 @@ public void DeviceLocator_Notifications_SearchResponseDefaultsToZeroMaxAge() eventSignal.Set(); }; - var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3)); + var t = deviceLocator.SearchAsync(TimeSpan.FromSeconds(3), TestContext.CancellationToken); System.Threading.Thread.Sleep(500); server.MockReceiveMessage(GetMockSearchResponseWithCustomCacheHeader(publishedDevice, publishedDevice.Udn, String.Format("CACHE-CONTROL: public"))); eventSignal.WaitOne(10000); @@ -983,7 +1006,7 @@ public void DeviceLocator_SearchAsync_RaisesDeviceAvailableOnResponse() }; - var task = deviceLocator.SearchAsync(TimeSpan.FromSeconds(2)); + var task = deviceLocator.SearchAsync(TimeSpan.FromSeconds(2), TestContext.CancellationToken); server.MockReceiveMessage(GetMockSearchResponse(publishedDevice, publishedDevice.Udn)); eventSignal.WaitOne(10000); Assert.IsTrue(receivedNotification); @@ -991,7 +1014,7 @@ public void DeviceLocator_SearchAsync_RaisesDeviceAvailableOnResponse() Assert.IsNotNull(results); Assert.IsTrue(results.Any()); - Assert.IsTrue(results.First().Usn == device.Usn); + Assert.AreEqual(device.Usn, results.First().Usn); } } @@ -1023,7 +1046,7 @@ public void DeviceLocator_SearchAsync_FiltersNotificationsDuringSearch() }; - var task = deviceLocator.SearchAsync(publishedDevice.Udn); + var task = deviceLocator.SearchAsync(publishedDevice.Udn, TestContext.CancellationToken); server.MockReceiveBroadcast(GetMockAliveNotification(publishedDevice2)); server.WaitForMessageToProcess(5000); eventSignal.Reset(); @@ -1035,7 +1058,7 @@ public void DeviceLocator_SearchAsync_FiltersNotificationsDuringSearch() Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().Usn == device.Usn); + Assert.AreEqual(device.Usn, results.First().Usn); } } @@ -1047,8 +1070,8 @@ public void DeviceLocator_IsSearching_ReturnsFalseWhenNoSearchInProgress() { var deviceLocator = new MockDeviceLocator(); Assert.IsFalse(deviceLocator.IsSearching); - var task = deviceLocator.SearchAsync(TimeSpan.FromSeconds(1.5)); - task.Wait(); + var task = deviceLocator.SearchAsync(TimeSpan.FromSeconds(1.5), TestContext.CancellationToken); + task.Wait(TestContext.CancellationToken); Assert.IsFalse(deviceLocator.IsSearching); } @@ -1058,10 +1081,10 @@ public void DeviceLocator_IsSearching_ReturnsTrueWhenSearchInProgress() { var deviceLocator = new MockDeviceLocator(); Assert.IsFalse(deviceLocator.IsSearching); - var task = deviceLocator.SearchAsync(TimeSpan.FromSeconds(1.5)); + var task = deviceLocator.SearchAsync(TimeSpan.FromSeconds(1.5), TestContext.CancellationToken); Assert.IsTrue(deviceLocator.IsSearching); - task.Wait(); + task.Wait(TestContext.CancellationToken); } #endregion @@ -1070,18 +1093,22 @@ public void DeviceLocator_IsSearching_ReturnsTrueWhenSearchInProgress() #region Event Arguments Tests - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void DeviceAvailableEventArgs_Constructor_ThrowsOnNullDevice() { - _ = new DeviceAvailableEventArgs(null, true); + Assert.Throws(() => + { + _ = new DeviceAvailableEventArgs(null, true); + }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void DeviceUnavailableEventArgs_Constructor_ThrowsOnNullDevice() { - _ = new DeviceUnavailableEventArgs(null, false); + Assert.Throws(() => + { + _ = new DeviceUnavailableEventArgs(null, false); + }); } #endregion @@ -1333,6 +1360,8 @@ private SsdpEmbeddedDevice CreateValidEmbeddedDevice(SsdpRootDevice rootDevice) return retVal; } + public TestContext TestContext { get; set; } + #endregion } diff --git a/src/Main/Test.Rssdp/DevicePublisherTests.cs b/src/Main/Test.Rssdp/DevicePublisherTests.cs index af8a6cb..6b65ecc 100644 --- a/src/Main/Test.Rssdp/DevicePublisherTests.cs +++ b/src/Main/Test.Rssdp/DevicePublisherTests.cs @@ -17,133 +17,63 @@ public class DevicePublisherTests #region Constructors - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void Publisher_Constructor_ThrowsOnNullCommsServer() { - _ = new SsdpRootDevice() + Assert.Throws(() => { - FriendlyName = "Basic Device 1", - Manufacturer = "Test Manufacturer", - ManufacturerUrl = new Uri("http://testmanufacturer.com"), - ModelDescription = "A test model device", - ModelName = "Test Model", - ModelNumber = "Model #1234", - ModelUrl = new Uri("http://modelurl.com"), - SerialNumber = "SN-123", - Uuid = System.Guid.NewGuid().ToString(), - Location = new Uri("http://testdevice:1700/xml") - }; - - _ = new TestDevicePublisher(null); + _ = new TestDevicePublisher(null); + }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void Publisher_Constructor_ThrowsOnNullOS() { - _ = new SsdpRootDevice() - { - FriendlyName = "Basic Device 1", - Manufacturer = "Test Manufacturer", - ManufacturerUrl = new Uri("http://testmanufacturer.com"), - ModelDescription = "A test model device", - ModelName = "Test Model", - ModelNumber = "Model #1234", - ModelUrl = new Uri("http://modelurl.com"), - SerialNumber = "SN-123", - Uuid = System.Guid.NewGuid().ToString(), - Location = new Uri("http://testdevice:1700/xml") - }; - var server = new MockCommsServer(); - _ = new TestDevicePublisher(server, null, "1.1"); + Assert.Throws(() => + { + _ = new TestDevicePublisher(server, null, "1.1"); + }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void Publisher_Constructor_ThrowsOnNullOSVersion() { - _ = new SsdpRootDevice() - { - FriendlyName = "Basic Device 1", - Manufacturer = "Test Manufacturer", - ManufacturerUrl = new Uri("http://testmanufacturer.com"), - ModelDescription = "A test model device", - ModelName = "Test Model", - ModelNumber = "Model #1234", - ModelUrl = new Uri("http://modelurl.com"), - SerialNumber = "SN-123", - Uuid = System.Guid.NewGuid().ToString(), - Location = new Uri("http://testdevice:1700/xml") - }; - var server = new MockCommsServer(); - _ = new TestDevicePublisher(server, "TestOS", null); + + Assert.Throws(() => { _ = new TestDevicePublisher(server, "TestOS", null); }); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void Publisher_Constructor_ThrowsOnEmptyOS() { - _ = new SsdpRootDevice() - { - FriendlyName = "Basic Device 1", - Manufacturer = "Test Manufacturer", - ManufacturerUrl = new Uri("http://testmanufacturer.com"), - ModelDescription = "A test model device", - ModelName = "Test Model", - ModelNumber = "Model #1234", - ModelUrl = new Uri("http://modelurl.com"), - SerialNumber = "SN-123", - Uuid = System.Guid.NewGuid().ToString(), - Location = new Uri("http://testdevice:1700/xml") - }; - var server = new MockCommsServer(); - _ = new TestDevicePublisher(server, String.Empty, "1.1"); + Assert.Throws(() => { _ = new TestDevicePublisher(server, String.Empty, "1.1"); }); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void Publisher_Constructor_ThrowsOnEmptyOSVersion() { - _ = new SsdpRootDevice() - { - FriendlyName = "Basic Device 1", - Manufacturer = "Test Manufacturer", - ManufacturerUrl = new Uri("http://testmanufacturer.com"), - ModelDescription = "A test model device", - ModelName = "Test Model", - ModelNumber = "Model #1234", - ModelUrl = new Uri("http://modelurl.com"), - SerialNumber = "SN-123", - Uuid = System.Guid.NewGuid().ToString(), - Location = new Uri("http://testdevice:1700/xml") - }; - var server = new MockCommsServer(); - _ = new TestDevicePublisher(server, "TestOS", String.Empty); + Assert.Throws(() => { _ = new TestDevicePublisher(server, "TestOS", String.Empty); }); } #endregion - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void Publisher_AddDevice_ThrowsOnNullDevice() { var server = new MockCommsServer(); var publisher = new TestDevicePublisher(server); - publisher.AddDevice(null); + Assert.Throws(() => { publisher.AddDevice(null); }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void Publisher_RemoveDevice_ThrowsOnNullDevice() { var server = new MockCommsServer(); var publisher = new TestDevicePublisher(server); - publisher.RemoveDevice(null); + Assert.Throws(() => { publisher.RemoveDevice(null); }); } #endregion @@ -182,7 +112,6 @@ public void Publisher_DisposeSetsIsDisposed() Assert.IsTrue(publisher.IsDisposed); } - [ExpectedException(typeof(System.ObjectDisposedException))] [TestMethod] public void Publisher_AddDeviceThrowsWhenDisposed() { @@ -203,10 +132,10 @@ public void Publisher_AddDeviceThrowsWhenDisposed() var server = new MockCommsServer(); var publisher = new TestDevicePublisher(server); publisher.Dispose(); - publisher.AddDevice(rootDevice); + + Assert.Throws(() => { publisher.AddDevice(rootDevice); }); } - [ExpectedException(typeof(System.ObjectDisposedException))] [TestMethod] public void Publisher_RemoveDeviceThrowsWhenDisposed() { @@ -227,7 +156,7 @@ public void Publisher_RemoveDeviceThrowsWhenDisposed() var server = new MockCommsServer(); var publisher = new TestDevicePublisher(server); publisher.Dispose(); - publisher.RemoveDevice(rootDevice); + Assert.Throws(() => { publisher.RemoveDevice(rootDevice); }); } #endregion @@ -258,7 +187,7 @@ public void Publisher_AddDevice_BroadcastsRootUpnpAliveNotification() var pnpRootDeviceNotifications = GetNotificationsForSearchTarget(aliveNotifications, SsdpConstants.PnpDeviceTypeRootDevice); Assert.AreEqual(1, publisher.Devices.Count()); - Assert.IsTrue(upnpRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, upnpRootDeviceNotifications.Count()); Assert.AreEqual(0, pnpRootDeviceNotifications.Count()); } } @@ -287,8 +216,8 @@ public void Publisher_AddDevice_BroadcastsRootPnpAliveNotification() var upnpRootDeviceNotifications = GetNotificationsForSearchTarget(aliveNotifications, SsdpConstants.UpnpDeviceTypeRootDevice); var pnpRootDeviceNotifications = GetNotificationsForSearchTarget(aliveNotifications, SsdpConstants.UpnpDeviceTypeRootDevice); - Assert.IsTrue(upnpRootDeviceNotifications.Count() >= 1); - Assert.IsTrue(pnpRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, upnpRootDeviceNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, pnpRootDeviceNotifications.Count()); } } @@ -317,7 +246,7 @@ public void Publisher_AddDevice_BroadcastsUdnNotification() var udnDeviceNotifications = GetNotificationsForSearchTarget(aliveNotifications, rootDevice.Udn); - Assert.IsTrue(udnDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, udnDeviceNotifications.Count()); } } @@ -344,7 +273,7 @@ public void Publisher_AddDevice_BroadcastsDeviceTypeAliveNotification() var deviceTypeNotifications = GetNotificationsForSearchTarget(aliveNotifications, rootDevice.FullDeviceType); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count()); } } @@ -378,8 +307,8 @@ public void Publisher_AddDevice_AddTreeSendsChildNotifications() }); Assert.AreEqual(1, rootDevice.Devices.Count()); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1); - Assert.IsTrue(udnNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, udnNotifications.Count()); Assert.AreEqual(0, rootDeviceNotificationsForEmbeddedDevice.Count()); } } @@ -416,8 +345,8 @@ public void Publisher_AddDevice_AddTreeSendsGrandchildNotifications() }); Assert.AreEqual(1, parentDevice.Devices.Count()); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1); - Assert.IsTrue(udnNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, udnNotifications.Count()); Assert.AreEqual(0, rootDeviceNotificationsForEmbeddedDevice.Count()); } } @@ -458,8 +387,8 @@ public void Publisher_AddDevice_AddChildSendsNotifications() return n.Headers.GetValues("USN").First() == embeddedDevice.Udn + "::" + embeddedDevice.FullDeviceType; }); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1); - Assert.IsTrue(udnNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, udnNotifications.Count()); Assert.AreEqual(0, rootDeviceNotificationsForEmbeddedDevice.Count()); } } @@ -502,8 +431,8 @@ public void Publisher_AddDevice_AddGrandchildSendsNotifications() return n.Headers.GetValues("USN").First() == embeddedDevice.Udn + "::" + embeddedDevice.FullDeviceType; }); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1); - Assert.IsTrue(udnNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, udnNotifications.Count()); Assert.AreEqual(0, rootDeviceNotificationsForEmbeddedDevice.Count()); } } @@ -555,7 +484,7 @@ public void Publisher_RemoveDevice_SendsRootUpnpByeByeNotification() var pnpRootDeviceNotifications = GetNotificationsForSearchTarget(byebyeNotifications, SsdpConstants.PnpDeviceTypeRootDevice); Assert.AreEqual(0, publisher.Devices.Count()); - Assert.IsTrue(upnpRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, upnpRootDeviceNotifications.Count()); Assert.AreEqual(0, pnpRootDeviceNotifications.Count()); } } @@ -585,8 +514,8 @@ public void Publisher_RemoveDevice_SendsRootPnpByeByeNotification() var pnpRootDeviceNotifications = GetNotificationsForSearchTarget(byebyeNotifications, SsdpConstants.PnpDeviceTypeRootDevice); Assert.AreEqual(0, publisher.Devices.Count()); - Assert.IsTrue(upnpRootDeviceNotifications.Count() >= 1); - Assert.IsTrue(pnpRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, upnpRootDeviceNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, pnpRootDeviceNotifications.Count()); } } @@ -613,7 +542,7 @@ public void Publisher_RemoveDevice_BroadcastsByeByeUdnNotification() var udnRootDeviceNotifications = GetNotificationsForSearchTarget(byebyeNotifications, rootDevice.Udn); - Assert.IsTrue(udnRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, udnRootDeviceNotifications.Count()); } } @@ -640,7 +569,7 @@ public void Publisher_RemoveDevice_BroadcastsByeByeDeviceTypeNotification() var deviceTypeRootDeviceNotifications = GetNotificationsForSearchTarget(byebyeNotifications, String.Format("urn:{0}", rootDevice.FullDeviceType)); - Assert.IsTrue(deviceTypeRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeRootDeviceNotifications.Count()); } } @@ -669,8 +598,8 @@ public void Publisher_RemoveDevice_RemoveTreeSendsChildNotifications() var udnRootDeviceNotifications = GetNotificationsForSearchTarget(byebyeNotifications, embeddedDevice.Udn); var deviceTypeRootDeviceNotifications = GetNotificationsForSearchTarget(byebyeNotifications, String.Format("urn:{0}", embeddedDevice.FullDeviceType)); - Assert.IsTrue(udnRootDeviceNotifications.Count() >= 1); - Assert.IsTrue(deviceTypeRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, udnRootDeviceNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeRootDeviceNotifications.Count()); } } @@ -701,8 +630,8 @@ public void Publisher_RemoveDevice_RemoveTreeSendsGrandchildNotifications() var udnRootDeviceNotifications = GetNotificationsForSearchTarget(byebyeNotifications, embeddedDevice.Udn); var deviceTypeRootDeviceNotifications = GetNotificationsForSearchTarget(byebyeNotifications, String.Format("urn:{0}", embeddedDevice.FullDeviceType)); - Assert.IsTrue(udnRootDeviceNotifications.Count() >= 1); - Assert.IsTrue(deviceTypeRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, udnRootDeviceNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeRootDeviceNotifications.Count()); } } @@ -736,8 +665,8 @@ public void Publisher_RemoveDevice_RemoveChildSendsNotifications() return n.Headers.GetValues("USN").First() == embeddedDevice.Udn + "::" + embeddedDevice.FullDeviceType; }); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1); - Assert.IsTrue(udnNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, udnNotifications.Count()); Assert.AreEqual(0, rootDeviceNotificationsForEmbeddedDevice.Count()); } } @@ -774,8 +703,8 @@ public void Publisher_RemoveDevice_RemoveGrandchildSendsNotifications() return n.Headers.GetValues("USN").First() == embeddedDevice.Udn + "::" + embeddedDevice.FullDeviceType; }); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1); - Assert.IsTrue(udnNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, udnNotifications.Count()); Assert.AreEqual(0, rootDeviceNotificationsForEmbeddedDevice.Count()); } } @@ -972,7 +901,6 @@ public void Publisher_RemoveService_DoesNotSendByeByeWhenServiceOfSameTypeRemain #region Periodic Alive Notifications [TestMethod] - [ExpectedException(typeof(ArgumentException))] public void Publisher_NotificationBroadcastInterval_ThrowsOnNegativeTimeSpan() { var rootDevice = CreateValidRootDevice(); @@ -981,7 +909,7 @@ public void Publisher_NotificationBroadcastInterval_ThrowsOnNegativeTimeSpan() var server = new MockCommsServer(); using (var publisher = new TestDevicePublisher(server)) { - publisher.NotificationBroadcastInterval = TimeSpan.FromSeconds(-1); + Assert.Throws(() => { publisher.NotificationBroadcastInterval = TimeSpan.FromSeconds(-1); }); } } @@ -1015,10 +943,10 @@ public void Publisher_SendsPeriodicAliveNotifications() var udnDeviceNotifications = GetNotificationsForSearchTarget(aliveNotifications, rootDevice.Udn); var deviceTypeNotifications = GetNotificationsForSearchTarget(aliveNotifications, rootDevice.FullDeviceType); - Assert.IsTrue(upnpRootDeviceNotifications.Count() >= 1, "Incorrect number of upnp root device notifications"); + Assert.IsGreaterThanOrEqualTo(1, upnpRootDeviceNotifications.Count(), "Incorrect number of upnp root device notifications"); Assert.AreEqual(0, pnpRootDeviceNotifications.Count(), "Incorrect number of pnp root device notifications"); - Assert.IsTrue(udnDeviceNotifications.Count() >= 1, "Incorrect number of udn device notifications"); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1, "Incorrect number of device type notifications"); + Assert.IsGreaterThanOrEqualTo(1, udnDeviceNotifications.Count(), "Incorrect number of udn device notifications"); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count(), "Incorrect number of device type notifications"); } } @@ -1090,10 +1018,10 @@ public void Publisher_SendsPeriodicAliveNotifications_RepeatsNotifications() var udnDeviceNotifications = GetNotificationsForSearchTarget(aliveNotifications, rootDevice.Udn); var deviceTypeNotifications = GetNotificationsForSearchTarget(aliveNotifications, rootDevice.FullDeviceType); - Assert.IsTrue(upnpRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, upnpRootDeviceNotifications.Count()); Assert.AreEqual(0, pnpRootDeviceNotifications.Count()); - Assert.IsTrue(udnDeviceNotifications.Count() >= 1); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, udnDeviceNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count()); } } @@ -1129,10 +1057,10 @@ public void Publisher_SendsPeriodicAliveNotifications_UsingConfiguredInterval() var udnDeviceNotifications = GetNotificationsForSearchTarget(aliveNotifications, rootDevice.Udn); var deviceTypeNotifications = GetNotificationsForSearchTarget(aliveNotifications, rootDevice.FullDeviceType); - Assert.IsTrue(upnpRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, upnpRootDeviceNotifications.Count()); Assert.AreEqual(0, pnpRootDeviceNotifications.Count()); - Assert.IsTrue(udnDeviceNotifications.Count() >= 1); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, udnDeviceNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count()); } } @@ -1170,10 +1098,10 @@ public void Publisher_SendsRepeatPeriodicAliveNotifications_UsingConfiguredInter var udnDeviceNotifications = GetNotificationsForSearchTarget(aliveNotifications, rootDevice.Udn); var deviceTypeNotifications = GetNotificationsForSearchTarget(aliveNotifications, rootDevice.FullDeviceType); - Assert.IsTrue(upnpRootDeviceNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, upnpRootDeviceNotifications.Count()); Assert.AreEqual(0, pnpRootDeviceNotifications.Count()); - Assert.IsTrue(udnDeviceNotifications.Count() >= 1); - Assert.IsTrue(deviceTypeNotifications.Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, udnDeviceNotifications.Count()); + Assert.IsGreaterThanOrEqualTo(1, deviceTypeNotifications.Count()); } } @@ -1228,7 +1156,7 @@ public void Publisher_SearchResponse_RespondsToSearchWithoutMXHeaderInRelaxedMod var searchResponses = GetSentMessages(server.SentMessages); Assert.AreEqual(0, searchResponses.Where((r) => !r.IsSuccessStatusCode).Count()); - Assert.IsTrue(GetResponses(searchResponses, rootDevice.FullDeviceType).Count() >= 1); + Assert.IsGreaterThanOrEqualTo(1, GetResponses(searchResponses, rootDevice.FullDeviceType).Count()); Assert.AreEqual(0, searchResponses.Where((r) => !r.Headers.GetValues("USN").First().StartsWith(rootDevice.Udn)).Count()); } } @@ -1255,7 +1183,7 @@ public void Publisher_SearchResponse_RespondsToSearchWithoutMXHeaderInDefaultMod var searchResponses = GetSentMessages(server.SentMessages); Assert.AreEqual(0, searchResponses.Where((r) => !r.IsSuccessStatusCode).Count()); - Assert.IsTrue(GetResponses(searchResponses, rootDevice.FullDeviceType).Count() >= 1, "No response for full device type"); + Assert.IsGreaterThanOrEqualTo(1, GetResponses(searchResponses, rootDevice.FullDeviceType).Count(), "No response for full device type"); Assert.AreEqual(0, searchResponses.Where((r) => !r.Headers.GetValues("USN").First().StartsWith(rootDevice.Udn)).Count()); } } @@ -1311,8 +1239,8 @@ public void Publisher_SearchResponse_AddCustomHeaders() var searchResponses = GetSentMessages(server.SentMessages); Assert.AreEqual(0, searchResponses.Where((r) => !r.IsSuccessStatusCode).Count()); - Assert.IsTrue(GetResponses(searchResponses, SsdpConstants.UpnpDeviceTypeRootDevice).Count() == 1); - Assert.IsTrue(GetResponses(searchResponses, SsdpConstants.PnpDeviceTypeRootDevice).Count() == 0); + Assert.AreEqual(1, GetResponses(searchResponses, SsdpConstants.UpnpDeviceTypeRootDevice).Count()); + Assert.AreEqual(0, GetResponses(searchResponses, SsdpConstants.PnpDeviceTypeRootDevice).Count()); Assert.AreEqual(0, searchResponses.Where((r) => !r.Headers.GetValues("USN").First().StartsWith(rootDevice.Udn)).Count()); Assert.AreEqual(0, searchResponses.Where((r) => !r.Headers.GetValues(testHeader.Name).First().StartsWith(testHeader.Value)).Count()); } @@ -1527,7 +1455,7 @@ public void Publisher_SearchResponse_IgnoresDuplicateSearchRequest() var searchResponses = GetSentMessages(server.SentMessages); Assert.AreEqual(0, searchResponses.Where((r) => !r.IsSuccessStatusCode).Count()); - Assert.IsTrue(GetResponses(searchResponses, SsdpConstants.UpnpDeviceTypeRootDevice).Count() == 1); + Assert.AreEqual(1, GetResponses(searchResponses, SsdpConstants.UpnpDeviceTypeRootDevice).Count()); } } @@ -1551,8 +1479,8 @@ public void Publisher_SearchResponse_RespondsToNonDuplicateSearchRequest() var searchResponses = GetSentMessages(server.SentMessages); Assert.AreEqual(0, searchResponses.Where((r) => !r.IsSuccessStatusCode).Count()); - Assert.IsTrue(searchResponses.Count() == 4); - Assert.IsTrue(GetResponses(searchResponses, SsdpConstants.UpnpDeviceTypeRootDevice).Count() == 2); + Assert.AreEqual(4, searchResponses.Count()); + Assert.AreEqual(2, GetResponses(searchResponses, SsdpConstants.UpnpDeviceTypeRootDevice).Count()); } } @@ -1591,7 +1519,7 @@ public void Publisher_SearchResponse_DoesNotIgnoreDelayedDuplicateSearchRequest( //System.Threading.Thread.Sleep(1000); Assert.AreEqual(0, searchResponses.Where((r) => !r.IsSuccessStatusCode).Count()); - Assert.IsTrue(GetResponses(searchResponses, SsdpConstants.UpnpDeviceTypeRootDevice).Count() > 0); + Assert.IsGreaterThan(0, GetResponses(searchResponses, SsdpConstants.UpnpDeviceTypeRootDevice).Count()); } } diff --git a/src/Main/Test.Rssdp/DeviceSerialisationTests.cs b/src/Main/Test.Rssdp/DeviceSerialisationTests.cs index 2f169a0..0472560 100644 --- a/src/Main/Test.Rssdp/DeviceSerialisationTests.cs +++ b/src/Main/Test.Rssdp/DeviceSerialisationTests.cs @@ -13,24 +13,28 @@ public class DeviceSerialisationTests private const string UpnpDeviceXmlNamespace = "urn:schemas-upnp-org:device-1-0"; - [ExpectedException(typeof(System.InvalidOperationException))] [TestMethod] public void ToDescriptionDocument_ThrowsWithNullUuid() { var rootDevice = CreateSampleRootDevice(); rootDevice.Uuid = null; - _ = rootDevice.ToDescriptionDocument(); + Assert.Throws(() => + { + _ = rootDevice.ToDescriptionDocument(); + }); } - [ExpectedException(typeof(System.InvalidOperationException))] [TestMethod] public void ToDescriptionDocument_ThrowsWithEmptyUuid() { var rootDevice = CreateSampleRootDevice(); rootDevice.Uuid = String.Empty; - _ = rootDevice.ToDescriptionDocument(); + Assert.Throws(() => + { + _ = rootDevice.ToDescriptionDocument(); + }); } [TestMethod] @@ -39,7 +43,7 @@ public void ToDescriptionDocument_CompletesWithNonEmptyResult() var rootDevice = CreateSampleRootDevice(); var descriptionDocument = rootDevice.ToDescriptionDocument(); - Assert.AreNotEqual(null, descriptionDocument); + Assert.IsNotNull(descriptionDocument); Assert.AreNotEqual(String.Empty, descriptionDocument); } @@ -50,7 +54,7 @@ public void ToDescriptionDocument_StartsWithXmlDeclaration() var descriptionDocument = rootDevice.ToDescriptionDocument(); - Assert.AreEqual(true, descriptionDocument.StartsWith("")); + Assert.StartsWith("", descriptionDocument); } [TestMethod] @@ -163,15 +167,13 @@ public void ToDescriptionDocument_ContainsEmbeddedDevices() Assert.IsTrue(deviceNodes.Where((n) => n.Elements(XName.Get("UDN", UpnpDeviceXmlNamespace)).First().Value == rootDevice.Devices.Last().Udn).Any()); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void ToDescriptionDocument_WriteDeviceDescriptionXml_ThrowsIfWriterNull() { var device = new MockCustomDevice(); - device.DoInvalidWrite(null, CreateSampleRootDevice()); + Assert.Throws(() => { device.DoInvalidWrite(null, CreateSampleRootDevice()); }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void ToDescriptionDocument_WriteDeviceDescriptionXml_ThrowsIfDeviceNull() { @@ -180,7 +182,7 @@ public void ToDescriptionDocument_WriteDeviceDescriptionXml_ThrowsIfDeviceNull() { using (var writer = XmlWriter.Create(ms)) { - device.DoInvalidWrite(writer, null); + Assert.Throws(() => { device.DoInvalidWrite(writer, null); }); } } } diff --git a/src/Main/Test.Rssdp/DiscoveredSsdpDeviceTests.cs b/src/Main/Test.Rssdp/DiscoveredSsdpDeviceTests.cs index 49a0696..5952373 100644 --- a/src/Main/Test.Rssdp/DiscoveredSsdpDeviceTests.cs +++ b/src/Main/Test.Rssdp/DiscoveredSsdpDeviceTests.cs @@ -163,7 +163,6 @@ public void DiscoveredDevice_GetDeviceInfo_MakesRequestWhenCachedDataExpired() } } - [ExpectedException(typeof(HttpRequestException))] [TestMethod] public void DiscoveredDevice_GetDeviceInfo_CreatesDefaultClient() { @@ -185,7 +184,10 @@ public void DiscoveredDevice_GetDeviceInfo_CreatesDefaultClient() DescriptionLocation = publishedDevice.Location }; - _ = discoveredDevice.GetDeviceInfo().GetAwaiter().GetResult(); + Assert.Throws(() => + { + _ = discoveredDevice.GetDeviceInfo().GetAwaiter().GetResult(); + }); } } diff --git a/src/Main/Test.Rssdp/DisposableManagedObjectTests.cs b/src/Main/Test.Rssdp/DisposableManagedObjectTests.cs index 6d1f6f1..5924bb1 100644 --- a/src/Main/Test.Rssdp/DisposableManagedObjectTests.cs +++ b/src/Main/Test.Rssdp/DisposableManagedObjectTests.cs @@ -21,7 +21,6 @@ public void DisposableManagedObject_DisposeSetsIsDisposed() Assert.IsTrue(testObject.IsDisposed); } - [ExpectedException(typeof(System.ObjectDisposedException))] [TestMethod] public void DisposableManagedObject_ThrowIfDisposedDoesWhatItSaysOnTheTin() { @@ -29,7 +28,11 @@ public void DisposableManagedObject_ThrowIfDisposedDoesWhatItSaysOnTheTin() var result = testObject.TestMethod(); Assert.AreEqual("oops", result); testObject.Dispose(); - result = testObject.TestMethod(); + + Assert.Throws(() => + { + _ = testObject.TestMethod(); + }); } } diff --git a/src/Main/Test.Rssdp/HttpParserTests.cs b/src/Main/Test.Rssdp/HttpParserTests.cs index e58fc90..1b1422f 100644 --- a/src/Main/Test.Rssdp/HttpParserTests.cs +++ b/src/Main/Test.Rssdp/HttpParserTests.cs @@ -17,36 +17,32 @@ public class HttpParserTests #region Argument Checking - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void HttpResponseParser_ThrowsOnNull() { var parser = new HttpResponseParser(); - parser.Parse(null); + Assert.Throws(() => parser.Parse(null)); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void HttpResponseParser_ThrowsOnEmpty() { var parser = new HttpResponseParser(); - parser.Parse(String.Empty); + Assert.Throws(() => parser.Parse(String.Empty)); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void HttpResponseParser_ThrowsOnMisingCrLf() { var parser = new HttpRequestParser(); - parser.Parse("HTTP/1.1 200 OK"); + Assert.Throws(() => parser.Parse("HTTP/1.1 200 OK")); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void HttpResponseParser_ThrowsOnInvalidHeader() { var parser = new HttpResponseParser(); - parser.Parse("HTTP1.1 200 OK" + Environment.NewLine); + Assert.Throws(() => parser.Parse("HTTP1.1 200 OK" + Environment.NewLine)); } #endregion @@ -57,28 +53,25 @@ public void HttpResponseParser_ThrowsOnInvalidHeader() #region Argument Checking - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void HttpRequestParser_ThrowsOnNull() { var parser = new HttpRequestParser(); - parser.Parse(null); + Assert.Throws(() => parser.Parse(null)); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void HttpRequestParser_ThrowsOnEmpty() { var parser = new HttpRequestParser(); - parser.Parse(String.Empty); + Assert.Throws(() => parser.Parse(String.Empty)); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void HttpRequestParser_ThrowsOnMisingCrLf() { var parser = new HttpRequestParser(); - parser.Parse("GET * HTTP/1.1"); + Assert.Throws(() => parser.Parse("GET * HTTP/1.1")); } [TestMethod] diff --git a/src/Main/Test.Rssdp/Properties/AssemblyInfo.cs b/src/Main/Test.Rssdp/Properties/AssemblyInfo.cs index 938b5cc..71af919 100644 --- a/src/Main/Test.Rssdp/Properties/AssemblyInfo.cs +++ b/src/Main/Test.Rssdp/Properties/AssemblyInfo.cs @@ -34,3 +34,5 @@ // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: Microsoft.VisualStudio.TestTools.UnitTesting.Parallelize(Workers = 1, Scope = Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope.MethodLevel)] \ No newline at end of file diff --git a/src/Main/Test.Rssdp/SsdpDevicePropertiesCollectionTests.cs b/src/Main/Test.Rssdp/SsdpDevicePropertiesCollectionTests.cs index e76e827..8d9838d 100644 --- a/src/Main/Test.Rssdp/SsdpDevicePropertiesCollectionTests.cs +++ b/src/Main/Test.Rssdp/SsdpDevicePropertiesCollectionTests.cs @@ -28,10 +28,12 @@ public void SsdpDevicePropertiesCollection_CapacityConstructor_SucceedsWithZeroV } [TestMethod] - [ExpectedException(typeof(System.ArgumentOutOfRangeException))] public void SsdpDevicePropertiesCollection_CapacityConstructor_FailsWithNegativeValue() { - _ = new SsdpDevicePropertiesCollection(-1); + Assert.Throws(() => + { + _ = new SsdpDevicePropertiesCollection(-1); + }); } #endregion @@ -39,22 +41,26 @@ public void SsdpDevicePropertiesCollection_CapacityConstructor_FailsWithNegative #region Add Tests [TestMethod] - [ExpectedException(typeof(System.ArgumentNullException))] public void SsdpDevicePropertiesCollection_Add_NullThrows() { var properties = new SsdpDevicePropertiesCollection(); - properties.Add(null); + Assert.Throws(() => + { + properties.Add(null); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void SsdpDevicePropertiesCollection_Add_EmptyFullNameThrows() { var properties = new SsdpDevicePropertiesCollection(); var p = new SsdpDeviceProperty(string.Empty, string.Empty, null); - properties.Add(p); + Assert.Throws(() => + { + properties.Add(p); + }); } #endregion @@ -62,39 +68,47 @@ public void SsdpDevicePropertiesCollection_Add_EmptyFullNameThrows() #region Remove Tests [TestMethod] - [ExpectedException(typeof(System.ArgumentNullException))] public void SsdpDevicePropertiesCollection_Remove_NullThrows() { var properties = new SsdpDevicePropertiesCollection(); - properties.Remove((SsdpDeviceProperty)null); + Assert.Throws(() => + { + properties.Remove((SsdpDeviceProperty)null); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void SsdpDevicePropertiesCollection_Remove_NullKeyThrows() { var properties = new SsdpDevicePropertiesCollection(); - properties.Remove((string)null); + Assert.Throws(() => + { + properties.Remove((string)null); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void SsdpDevicePropertiesCollection_Remove_EmptyKeyThrows() { var properties = new SsdpDevicePropertiesCollection(); - properties.Remove(String.Empty); + Assert.Throws(() => + { + properties.Remove(String.Empty); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void SsdpDevicePropertiesCollection_Remove_EmptyFullNameThrows() { var properties = new SsdpDevicePropertiesCollection(); var p = new SsdpDeviceProperty(string.Empty, string.Empty, null); - properties.Remove(p); + Assert.Throws(() => + { + properties.Remove(p); + }); } [TestMethod] @@ -105,7 +119,7 @@ public void SsdpDevicePropertiesCollection_Remove_RemoveInstanceSucceeds() properties.Add(p); - Assert.AreEqual(true, properties.Remove(p)); + Assert.IsTrue(properties.Remove(p)); Assert.AreEqual(0, properties.Count); } @@ -118,7 +132,7 @@ public void SsdpDevicePropertiesCollection_Remove_RemoveInstanceForDifferentInst properties.Add(p); - Assert.AreEqual(false, properties.Remove(p2)); + Assert.IsFalse(properties.Remove(p2)); Assert.AreEqual(1, properties.Count); } @@ -130,7 +144,7 @@ public void SsdpDevicePropertiesCollection_Remove_RemoveByKeySucceeds() properties.Add(p); - Assert.AreEqual(true, properties.Remove(p.FullName)); + Assert.IsTrue(properties.Remove(p.FullName)); Assert.AreEqual(0, properties.Count); } @@ -139,38 +153,47 @@ public void SsdpDevicePropertiesCollection_Remove_RemoveByKeySucceeds() #region Contains Tests [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void SsdpDevicePropertiesCollection_Contains_NullNameThrows() { var properties = new SsdpDevicePropertiesCollection(); - properties.Contains((string)null); + Assert.Throws(() => + { + properties.Contains((string)null); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void SsdpDevicePropertiesCollection_Contains_EmptyNameThrows() { var properties = new SsdpDevicePropertiesCollection(); - properties.Contains(String.Empty); + Assert.Throws(() => + { + properties.Contains(String.Empty); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentNullException))] public void SsdpDevicePropertiesCollection_Contains_NullPropertyThrows() { var properties = new SsdpDevicePropertiesCollection(); - properties.Contains((SsdpDeviceProperty)null); + Assert.Throws(() => + { + properties.Contains((SsdpDeviceProperty)null); + }); } [TestMethod] - [ExpectedException(typeof(System.ArgumentException))] public void SsdpDevicePropertiesCollection_Contains_PropertyWithEmptyNameThrows() { var properties = new SsdpDevicePropertiesCollection(); var p = new SsdpDeviceProperty(string.Empty, string.Empty, null); - properties.Contains(p); + Assert.Throws(() => + { + properties.Contains(p); + }); } + [TestMethod] public void SsdpDevicePropertiesCollection_Contains_ReturnsTrueForExistingKey() { @@ -179,7 +202,7 @@ public void SsdpDevicePropertiesCollection_Contains_ReturnsTrueForExistingKey() properties.Add(prop); - Assert.AreEqual(true, properties.Contains(prop.FullName)); + Assert.IsTrue(properties.Contains(prop.FullName)); } [TestMethod] @@ -190,7 +213,7 @@ public void SsdpDevicePropertiesCollection_Contains_ReturnsFalseForNonExistentKe properties.Add(prop); - Assert.AreEqual(false, properties.Contains("NotAValidKey")); + Assert.IsFalse(properties.Contains("NotAValidKey")); } [TestMethod] @@ -201,7 +224,7 @@ public void SsdpDevicePropertiesCollection_Contains_ReturnsTrueForExistingItem() properties.Add(prop); - Assert.AreEqual(true, properties.Contains(prop)); + Assert.IsTrue(properties.Contains(prop)); } [TestMethod] @@ -214,7 +237,7 @@ public void SsdpDevicePropertiesCollection_Contains_ReturnsFalseForExistingKeyDi properties.Add(prop); - Assert.AreEqual(false, properties.Contains(prop2)); + Assert.IsFalse(properties.Contains(prop2)); } [TestMethod] @@ -226,7 +249,7 @@ public void SsdpDevicePropertiesCollection_Contains_ReturnsFalseForNonExistentPr properties.Add(prop); - Assert.AreEqual(false, properties.Contains(prop2)); + Assert.IsFalse(properties.Contains(prop2)); } #endregion @@ -242,9 +265,9 @@ public void SsdpDevicePropertiesCollection_GenericGetEnumerator_Success() properties.Add(prop); var enumerator = properties.GetEnumerator(); - Assert.AreEqual(true, enumerator.MoveNext()); + Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual(prop, enumerator.Current); - Assert.AreEqual(false, enumerator.MoveNext()); + Assert.IsFalse(enumerator.MoveNext()); } [TestMethod] @@ -256,9 +279,9 @@ public void SsdpDevicePropertiesCollection_GetEnumerator_Success() properties.Add(prop); var enumerator = ((IEnumerable)properties).GetEnumerator(); - Assert.AreEqual(true, enumerator.MoveNext()); + Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual(prop, enumerator.Current); - Assert.AreEqual(false, enumerator.MoveNext()); + Assert.IsFalse(enumerator.MoveNext()); } #endregion @@ -275,7 +298,6 @@ public void SsdpDevicePropertiesCollection_Indexer_Succeeds() Assert.AreEqual(p, properties[p.FullName]); } - [ExpectedException(typeof(System.Collections.Generic.KeyNotFoundException))] [TestMethod] public void SsdpDevicePropertiesCollection_Indexer_ThrowsOnUnknownKey() { @@ -284,7 +306,10 @@ public void SsdpDevicePropertiesCollection_Indexer_ThrowsOnUnknownKey() properties.Add(p); - Assert.AreEqual(p, properties["NotAValidKey"]); + Assert.Throws(() => + { + var value = properties["NotAValidKey"]; + }); } #endregion diff --git a/src/Main/Test.Rssdp/SsdpDeviceTests.cs b/src/Main/Test.Rssdp/SsdpDeviceTests.cs index 7208c5f..5c7c334 100644 --- a/src/Main/Test.Rssdp/SsdpDeviceTests.cs +++ b/src/Main/Test.Rssdp/SsdpDeviceTests.cs @@ -14,12 +14,14 @@ public class SsdpDeviceTests #region AddDevice Tests - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void SsdpDevice_AddDevice_ThrowsArgumentNullOnNullDevice() { var rootDevice = new SsdpRootDevice(); - rootDevice.AddDevice(null); + Assert.Throws(() => + { + rootDevice.AddDevice(null); + }); } [TestMethod] @@ -68,16 +70,17 @@ public void SsdpDevice_AddDevice_SetsRootDeviceOnDescendants() Assert.AreEqual(rootDevice, embeddedDevice2.RootDevice); } - [ExpectedException(typeof(InvalidOperationException))] [TestMethod] public void SsdpDevice_AddDevice_ThrowsAddingDeviceToSelf() { var embeddedDevice = new SsdpEmbeddedDevice(); - embeddedDevice.AddDevice(embeddedDevice); + Assert.Throws(() => + { + embeddedDevice.AddDevice(embeddedDevice); + }); } - [ExpectedException(typeof(InvalidOperationException))] [TestMethod] public void SsdpDevice_AddDevice_ThrowsAddingDeviceToMultipleParents() { @@ -88,7 +91,10 @@ public void SsdpDevice_AddDevice_ThrowsAddingDeviceToMultipleParents() rootDevice1.AddDevice(embeddedDevice); - rootDevice2.AddDevice(embeddedDevice); + Assert.Throws(() => + { + rootDevice2.AddDevice(embeddedDevice); + }); } #endregion @@ -129,30 +135,36 @@ public void SsdpDevice_RemoveDevice_DuplicateRemoveDoesNothing() Assert.AreEqual(0, rootDevice.Devices.Count()); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void SsdpDevice_RemoveDevice_ThrowsArgumentNullOnNullDevice() { var rootDevice = new SsdpRootDevice(); - rootDevice.RemoveDevice(null); + Assert.Throws(() => + { + rootDevice.RemoveDevice(null); + }); } #endregion #region Constructor Tests - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void SsdpDevice_ConstructorThrowsArgumentNullIfNotRootDevice() { - _ = new SsdpEmbeddedDevice(null, new System.Xml.XmlReaderSettings()); + Assert.Throws(() => + { + _ = new SsdpEmbeddedDevice(null, new System.Xml.XmlReaderSettings()); + }); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void DeviceEventArgs_ConstructorThrowsOnNullDevice() { - _ = new DeviceEventArgs(null); + Assert.Throws(() => + { + _ = new DeviceEventArgs(null); + }); } #endregion @@ -166,7 +178,7 @@ public void SsdpDevice_NullDeviceTypeNamespaceReturnsNull() { DeviceTypeNamespace = null }; - Assert.AreEqual(null, rootDevice.DeviceTypeNamespace); + Assert.IsNull(rootDevice.DeviceTypeNamespace); } [TestMethod] @@ -190,7 +202,7 @@ public void SsdpDevice_NullDeviceTypeReturnsNull() { DeviceType = null }; - Assert.AreEqual(null, rootDevice.DeviceType); + Assert.IsNull(rootDevice.DeviceType); } [TestMethod] @@ -240,7 +252,7 @@ public void SsdpDevice_DeviceToRootDeviceReturnsNullWhenNoRootAssigned() { var device = new SsdpEmbeddedDevice(); - Assert.AreEqual(null, device.RootDevice); + Assert.IsNull(device.RootDevice); } [TestMethod] @@ -255,13 +267,15 @@ public void SsdpDevice_RootDeviceFromDeviceDescriptionXml() #region Extension Tests - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void SsdpDevice_ToRootDevice_ThrowsOnNullSource() { SsdpDevice device = null; - device.ToRootDevice(); + Assert.Throws(() => + { + device.ToRootDevice(); + }); } #endregion @@ -541,7 +555,7 @@ public void Deserialisation_XmlWithNewlines_HandlesIconListAndFollowingPropertie Assert.AreEqual("minimserver.com", device.Manufacturer); Assert.AreEqual("MinimServer", device.ModelName); Assert.AreEqual("uuid:df5bda28-1b1a-4a62-89ed-0acc041ee8e4", device.Udn); - Assert.AreEqual(4, device.Icons.Count); + Assert.HasCount(4, device.Icons); Assert.AreEqual(4, device.Icons.Select(icon => icon.Url.ToString()).Distinct().Count()); } @@ -555,7 +569,7 @@ public void Deserialisation_XmlWithoutNewlines_HandlesIconListAndFollowingProper Assert.AreEqual("minimserver.com", device.Manufacturer); Assert.AreEqual("MinimServer", device.ModelName); Assert.AreEqual("uuid:df5bda28-1b1a-4a62-89ed-0acc041ee8e4", device.Udn); - Assert.AreEqual(4, device.Icons.Count); + Assert.HasCount(4, device.Icons); var d = device.Icons.Select(icon => icon.Url.ToString()).Distinct(); Assert.AreEqual(4, device.Icons.Select(icon => icon.Url.ToString()).Distinct().Count()); } @@ -590,13 +604,13 @@ public void DeserialisationHandlesEmptyCustomProperties() var device = new SsdpRootDevice(new Uri("http://192.168.1.11/UPnP/DeviceDescription"), TimeSpan.FromMinutes(30), docString); Assert.IsFalse(device.CustomProperties.Contains("pv:extension")); - Assert.AreEqual(device.Manufacturer, "PacketVideo"); + Assert.AreEqual("PacketVideo", device.Manufacturer); Assert.AreEqual(device.ManufacturerUrl, new Uri("http://www.pv.com")); - Assert.AreEqual(device.ModelName, "TwonkyServer"); + Assert.AreEqual("TwonkyServer", device.ModelName); Assert.AreEqual(device.ModelUrl, new Uri("http://www.twonky.com")); - Assert.AreEqual(device.ModelDescription, "TwonkyServer (Windows, T-206)"); - Assert.AreEqual(device.ModelNumber, "8.4"); - Assert.AreEqual(device.SerialNumber, "8.4"); + Assert.AreEqual("TwonkyServer (Windows, T-206)", device.ModelDescription); + Assert.AreEqual("8.4", device.ModelNumber); + Assert.AreEqual("8.4", device.SerialNumber); } [TestMethod] @@ -607,25 +621,27 @@ public void DeserialisationHandlesNonStandardXmlCharacters() var device = new SsdpRootDevice(new Uri("http://192.168.5.117/UPnP/DeviceDescription"), TimeSpan.FromMinutes(30), docString); Assert.IsFalse(device.CustomProperties.Contains("pv:extension")); - Assert.AreEqual(device.Manufacturer, "Denon"); + Assert.AreEqual("Denon", device.Manufacturer); Assert.AreEqual(device.ManufacturerUrl, new Uri("http://www.denon.com")); - Assert.AreEqual(device.ModelName, "*AVR-E400"); + Assert.AreEqual("*AVR-E400", device.ModelName); Assert.AreEqual(device.ModelUrl, new Uri("http://www.denon.com")); - Assert.AreEqual(device.ModelDescription, "AV SURROUND RECEIVER"); - Assert.AreEqual(device.ModelNumber, "E400"); - Assert.AreEqual(device.SerialNumber, "0005CD2BA891"); + Assert.AreEqual("AV SURROUND RECEIVER", device.ModelDescription); + Assert.AreEqual("E400", device.ModelNumber); + Assert.AreEqual("0005CD2BA891", device.SerialNumber); } #endregion #region Service Tests - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void SsdpDevice_AddService_ThrowsArgumentNullOnNullService() { var rootDevice = new SsdpRootDevice(); - rootDevice.AddService(null); + Assert.Throws(() => + { + rootDevice.AddService(null); + }); } [TestMethod] @@ -658,12 +674,14 @@ public void SsdpDevice_AddService_DuplicateAddDoesNothing() Assert.AreEqual(1, rootDevice.Services.Count()); } - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void SsdpDevice_RemoveService_ThrowsArgumentNullOnNullService() { var rootDevice = new SsdpRootDevice(); - rootDevice.AddService(null); + Assert.Throws(() => + { + rootDevice.RemoveService(null); + }); } [TestMethod] diff --git a/src/Main/Test.Rssdp/SsdpServiceTests.cs b/src/Main/Test.Rssdp/SsdpServiceTests.cs index 0c60f2a..47c6ebe 100644 --- a/src/Main/Test.Rssdp/SsdpServiceTests.cs +++ b/src/Main/Test.Rssdp/SsdpServiceTests.cs @@ -14,24 +14,28 @@ public class SsdpServiceTests #region Constructor Tests - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void SsdpService_ConstructorThrowsArgumentNullIfXmlStringNull() { - var device = new SsdpService(null); + Assert.Throws(() => + { + var device = new SsdpService(null); + }); } - [ExpectedException(typeof(System.ArgumentException))] [TestMethod] public void SsdpService_ConstructorThrowsArgumentNullIfXmlStringEmpty() { - var device = new SsdpService(String.Empty); + Assert.Throws(() => + { + var device = new SsdpService(String.Empty); + }); } [TestMethod] public void SsdpService_ConstructsOkWithDefaultConstructor() { - var device = new SsdpService(); + _ = new SsdpService(); } #endregion @@ -41,16 +45,20 @@ public void SsdpService_ConstructsOkWithDefaultConstructor() [TestMethod] public void SsdpService_NullServiceTypeNamespaceReturnsNull() { - var service = new SsdpService(); - service.ServiceTypeNamespace = null; - Assert.AreEqual(null, service.ServiceTypeNamespace); + var service = new SsdpService + { + ServiceTypeNamespace = null + }; + Assert.IsNull(service.ServiceTypeNamespace); } [TestMethod] public void SsdpService_EmptyDeviceTypeNamespaceReturnsEmpty() { - var service = new SsdpService(); - service.ServiceTypeNamespace = String.Empty; + var service = new SsdpService + { + ServiceTypeNamespace = String.Empty + }; Assert.AreEqual(String.Empty, service.ServiceTypeNamespace); } @@ -61,43 +69,53 @@ public void SsdpService_EmptyDeviceTypeNamespaceReturnsEmpty() [TestMethod] public void SsdpService_NullServiceTypeReturnsNull() { - var service = new SsdpService(); - service.ServiceType = null; - Assert.AreEqual(null, service.ServiceType); + var service = new SsdpService + { + ServiceType = null + }; + Assert.IsNull(service.ServiceType); } [TestMethod] public void SsdpService_EmptyServiceTypeReturnsEmpty() { - var service = new SsdpService(); - service.ServiceType = String.Empty; + var service = new SsdpService + { + ServiceType = String.Empty + }; Assert.AreEqual(String.Empty, service.ServiceType); } [TestMethod] public void SsdpService_FullServiceTypesReturnsStringWithNullValues() { - var service = new SsdpService(); - service.ServiceType = null; - service.ServiceTypeNamespace = null; + var service = new SsdpService + { + ServiceType = null, + ServiceTypeNamespace = null + }; Assert.AreEqual("urn::service::1", service.FullServiceType); } [TestMethod] public void SsdpService_FullServiceTypesReturnsExpectedString() { - var service = new SsdpService(); - service.ServiceType = "testservicetype"; - service.ServiceTypeNamespace = "my-test-namespace"; + var service = new SsdpService + { + ServiceType = "testservicetype", + ServiceTypeNamespace = "my-test-namespace" + }; Assert.AreEqual("urn:my-test-namespace:service:testservicetype:1", service.FullServiceType); } [TestMethod] public void SsdpService_FullServiceTypesReplacesDotsInVendorNamespace() { - var service = new SsdpService(); - service.ServiceType = "testservicetype"; - service.ServiceTypeNamespace = "my.test.namespace.org"; + var service = new SsdpService + { + ServiceType = "testservicetype", + ServiceTypeNamespace = "my.test.namespace.org" + }; Assert.AreEqual("urn:my-test-namespace-org:service:testservicetype:1", service.FullServiceType); } diff --git a/src/Main/Test.Rssdp/Test.Rssdp.csproj b/src/Main/Test.Rssdp/Test.Rssdp.csproj index bf36a9b..4062c56 100644 --- a/src/Main/Test.Rssdp/Test.Rssdp.csproj +++ b/src/Main/Test.Rssdp/Test.Rssdp.csproj @@ -1,44 +1,25 @@  - - net48 - Library - TestRssdp - ..\ - true - false - - - - - - - - - - - - - - - PreserveNewest - - - - - - - False - - - False - - - False - - - False - - - - - \ No newline at end of file + + net48 + Library + TestRssdp + false + true + + + + + + + + + + + + + + + PreserveNewest + + + diff --git a/src/Main/Test.Rssdp/UPnP10DeviceValidatorTests.cs b/src/Main/Test.Rssdp/UPnP10DeviceValidatorTests.cs index d4b5ddd..b41a2cf 100644 --- a/src/Main/Test.Rssdp/UPnP10DeviceValidatorTests.cs +++ b/src/Main/Test.Rssdp/UPnP10DeviceValidatorTests.cs @@ -15,14 +15,17 @@ public class UPnP10DeviceValidatorTests #region Root Device Validations - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void UPnP10DeviceValidator_ThrowsOnNullRootDevice() { SsdpRootDevice testDevice = null; var validator = new Upnp10DeviceValidator(); - var results = validator.GetValidationErrors(testDevice); + Assert.Throws(() => + { + _ = validator.GetValidationErrors(testDevice); + }); + } [TestMethod] @@ -68,7 +71,7 @@ public void UPnP10DeviceValidator_RootDeviceRequiresLocation() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("location", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("location", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -92,21 +95,24 @@ public void UPnP10DeviceValidator_RootDeviceLocationMustBeAbsolute() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("location", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("location", StringComparison.OrdinalIgnoreCase)); } #endregion #region Device Validations - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void UPnP10DeviceValidator_ThrowsOnNullDevice() { SsdpDevice testDevice = null; var validator = new Upnp10DeviceValidator(); - var results = validator.GetValidationErrors(testDevice); + + Assert.Throws(() => + { + _ = validator.GetValidationErrors(testDevice); + }); } [TestMethod] @@ -225,7 +231,7 @@ public void UPnP10DeviceValidator_FailsNonNumericUpcCode() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("UPC", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("UPC", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -265,7 +271,7 @@ public void UPnP10DeviceValidator_FailsUpcCodeLessThan12Chars() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("UPC", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("UPC", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -305,7 +311,7 @@ public void UPnP10DeviceValidator_FailsUpcCodeMoreThan12Chars() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("UPC", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("UPC", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -347,7 +353,7 @@ public void UPnP10DeviceValidator_FailsNullUuid() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("uuid", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("uuid", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -385,7 +391,7 @@ public void UPnP10DeviceValidator_FailsEmptyUuid() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("uuid", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("uuid", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -428,7 +434,7 @@ public void UPnP10DeviceValidator_FailsUdnNotStartingWithPrefix() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("udn", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("udn", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -467,7 +473,7 @@ public void UPnP10DeviceValidator_FailsUdnNotUsingUuid() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("uuid", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("uuid", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -535,7 +541,7 @@ public void UPnP10DeviceValidator_FailsNullDeviceType() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(rootDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("DeviceType", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("DeviceType", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -559,7 +565,7 @@ public void UPnP10DeviceValidator_FailsEmptyDeviceType() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(rootDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("DeviceType", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("DeviceType", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -587,7 +593,7 @@ public void UPnP10DeviceValidator_FailsDeviceVersionZero() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(rootDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("DeviceVersion", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("DeviceVersion", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -611,7 +617,7 @@ public void UPnP10DeviceValidator_FailsDeviceVersionLessThanZero() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(rootDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("DeviceVersion", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("DeviceVersion", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -654,7 +660,7 @@ public void UPnP10DeviceValidator_FailsDeviceTypeNamespaceWithPeriods() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("DeviceTypeNamespace", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("DeviceTypeNamespace", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -693,7 +699,7 @@ public void UPnP10DeviceValidator_FailsDeviceTypeNamespaceOverMaxLength() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("DeviceTypeNamespace", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("DeviceTypeNamespace", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -717,7 +723,7 @@ public void UPnP10DeviceValidator_FailsNullDeviceTypeNamespace() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(rootDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("DeviceTypeNamespace", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("DeviceTypeNamespace", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -741,7 +747,7 @@ public void UPnP10DeviceValidator_FailsEmptyDeviceTypeNamespace() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(rootDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("DeviceTypeNamespace", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("DeviceTypeNamespace", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -784,7 +790,7 @@ public void UPnP10DeviceValidator_FailsNullFriendlyName() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("FriendlyName", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("FriendlyName", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -823,7 +829,7 @@ public void UPnP10DeviceValidator_FailsEmptyFriendlyName() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("FriendlyName", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("FriendlyName", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -862,7 +868,7 @@ public void UPnP10DeviceValidator_FriendlyNameOverMaxLength() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("FriendlyName", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("FriendlyName", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -905,7 +911,7 @@ public void UPnP10DeviceValidator_FailsNullManufacturer() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("Manufacturer", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("Manufacturer", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -944,7 +950,7 @@ public void UPnP10DeviceValidator_FailsEmptyManufacturer() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("Manufacturer", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("Manufacturer", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -983,7 +989,7 @@ public void UPnP10DeviceValidator_FailsManufacturerOverMaxLength() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("Manufacturer", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("Manufacturer", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -1026,7 +1032,7 @@ public void UPnP10DeviceValidator_FailsNullModelName() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("ModelName", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("ModelName", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -1065,7 +1071,7 @@ public void UPnP10DeviceValidator_FailsEmptyModelName() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("ModelName", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("ModelName", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -1104,7 +1110,7 @@ public void UPnP10DeviceValidator_FailsModelNameOverMaxLength() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("ModelName", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("ModelName", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -1147,7 +1153,7 @@ public void UPnP10DeviceValidator_FailsModelNumberOverMaxLength() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("ModelNumber", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("ModelNumber", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -1190,7 +1196,7 @@ public void UPnP10DeviceValidator_FailsSerialNumberOverMaxLength() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("SerialNumber", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("SerialNumber", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -1233,7 +1239,7 @@ public void UPnP10DeviceValidator_FailsModelDescriptionOverMaxLength() var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); - Assert.IsTrue(results.First().IndexOf("ModelDescription", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("ModelDescription", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -1243,20 +1249,6 @@ public void UPnP10DeviceValidator_FailsModelDescriptionOverMaxLength() [TestMethod] public void UPnP10DeviceValidator_PassesValidIcon() { - var rootDevice = new SsdpRootDevice() - { - FriendlyName = "Basic Device 1", - Manufacturer = "Test Manufacturer", - ManufacturerUrl = new Uri("http://testmanufacturer.com"), - ModelDescription = "A test model device", - ModelName = "Test Model", - ModelNumber = "Model #1234", - ModelUrl = new Uri("http://modelurl.com"), - SerialNumber = "SN-123", - Uuid = System.Guid.NewGuid().ToString(), - Location = new Uri("http://testdevice:1700/xml"), - }; - var testDevice = new SsdpEmbeddedDevice() { DeviceType = "TestEmbeddedDevice", @@ -1335,26 +1327,12 @@ public void UPnP10DeviceValidator_FailsIconNullMimeType() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("mime type", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("mime type", StringComparison.OrdinalIgnoreCase)); } [TestMethod] public void UPnP10DeviceValidator_FailsIconEmptyMimeType() { - var rootDevice = new SsdpRootDevice() - { - FriendlyName = "Basic Device 1", - Manufacturer = "Test Manufacturer", - ManufacturerUrl = new Uri("http://testmanufacturer.com"), - ModelDescription = "A test model device", - ModelName = "Test Model", - ModelNumber = "Model #1234", - ModelUrl = new Uri("http://modelurl.com"), - SerialNumber = "SN-123", - Uuid = System.Guid.NewGuid().ToString(), - Location = new Uri("http://testdevice:1700/xml"), - }; - var testDevice = new SsdpEmbeddedDevice() { DeviceType = "TestEmbeddedDevice", @@ -1384,7 +1362,7 @@ public void UPnP10DeviceValidator_FailsIconEmptyMimeType() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("mime type", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("mime type", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -1434,7 +1412,7 @@ public void UPnP10DeviceValidator_FailsIconNullUri() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("url", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("url", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -1484,7 +1462,7 @@ public void UPnP10DeviceValidator_FailsZeroColorDepth() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("colordepth", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("colordepth", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -1534,26 +1512,12 @@ public void UPnP10DeviceValidator_FailsNegativeColorDepth() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("colordepth", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("colordepth", StringComparison.OrdinalIgnoreCase)); } [TestMethod] public void UPnP10DeviceValidator_FailsZeroWidth() { - var rootDevice = new SsdpRootDevice() - { - FriendlyName = "Basic Device 1", - Manufacturer = "Test Manufacturer", - ManufacturerUrl = new Uri("http://testmanufacturer.com"), - ModelDescription = "A test model device", - ModelName = "Test Model", - ModelNumber = "Model #1234", - ModelUrl = new Uri("http://modelurl.com"), - SerialNumber = "SN-123", - Uuid = System.Guid.NewGuid().ToString(), - Location = new Uri("http://testdevice:1700/xml"), - }; - var testDevice = new SsdpEmbeddedDevice() { DeviceType = "TestEmbeddedDevice", @@ -1583,7 +1547,7 @@ public void UPnP10DeviceValidator_FailsZeroWidth() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("width", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("width", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -1633,26 +1597,12 @@ public void UPnP10DeviceValidator_FailsNegativeWidth() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("width", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("width", StringComparison.OrdinalIgnoreCase)); } [TestMethod] public void UPnP10DeviceValidator_FailsZeroHeight() { - var rootDevice = new SsdpRootDevice() - { - FriendlyName = "Basic Device 1", - Manufacturer = "Test Manufacturer", - ManufacturerUrl = new Uri("http://testmanufacturer.com"), - ModelDescription = "A test model device", - ModelName = "Test Model", - ModelNumber = "Model #1234", - ModelUrl = new Uri("http://modelurl.com"), - SerialNumber = "SN-123", - Uuid = System.Guid.NewGuid().ToString(), - Location = new Uri("http://testdevice:1700/xml"), - }; - var testDevice = new SsdpEmbeddedDevice() { DeviceType = "TestEmbeddedDevice", @@ -1682,7 +1632,7 @@ public void UPnP10DeviceValidator_FailsZeroHeight() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("width", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("width", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -1732,7 +1682,7 @@ public void UPnP10DeviceValidator_FailsNegativeHeight() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); - Assert.IsTrue(results.First().IndexOf("width", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("width", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -1777,7 +1727,7 @@ public void UPnP10DeviceValidator_ValidatesNestedChildDevices() var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreNotEqual(0, results.Count()); - Assert.IsTrue(results.First().IndexOf("Embedded Device", StringComparison.OrdinalIgnoreCase) >= 0); + Assert.IsGreaterThanOrEqualTo(0, results.First().IndexOf("Embedded Device", StringComparison.OrdinalIgnoreCase)); } #endregion @@ -2084,14 +2034,17 @@ public void UPnP10DeviceValidator_FailsOnMissingControlUrl() #region ThrowIfInvalidTests - [ExpectedException(typeof(System.ArgumentNullException))] [TestMethod] public void UPnP10DeviceValidator_ThrowIfInvalidThrowsOnNullRootDevice() { SsdpRootDevice testDevice = null; var validator = new Upnp10DeviceValidator(); - validator.ThrowIfDeviceInvalid(testDevice); + + Assert.Throws(() => + { + validator.ThrowIfDeviceInvalid(testDevice); + }); } [TestMethod] @@ -2115,7 +2068,6 @@ public void UPnP10DeviceValidator_ThrowIfInvalidPassesCorrectRootDevice() validator.ThrowIfDeviceInvalid(testDevice); } - [ExpectedException(typeof(System.InvalidOperationException))] [TestMethod] public void UPnP10DeviceValidator_ThrowIfInvalidThrowsOnValidationError() { @@ -2134,7 +2086,10 @@ public void UPnP10DeviceValidator_ThrowIfInvalidThrowsOnValidationError() }; var validator = new Upnp10DeviceValidator(); - validator.ThrowIfDeviceInvalid(testDevice); + Assert.Throws(() => + { + validator.ThrowIfDeviceInvalid(testDevice); + }); } #endregion diff --git a/src/RssdpPackageTests/RssdpPackageTestConsoleApp/RssdpPackageTestConsoleApp.csproj b/src/RssdpPackageTests/RssdpPackageTestConsoleApp/RssdpPackageTestConsoleApp.csproj index f9eb77b..2170ea8 100644 --- a/src/RssdpPackageTests/RssdpPackageTestConsoleApp/RssdpPackageTestConsoleApp.csproj +++ b/src/RssdpPackageTests/RssdpPackageTestConsoleApp/RssdpPackageTestConsoleApp.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/RssdpPackageTests/RssdpUwpPackageTests/RssdpUwpPackageTests.csproj b/src/RssdpPackageTests/RssdpUwpPackageTests/RssdpUwpPackageTests.csproj index 2ee1509..e5141ab 100644 --- a/src/RssdpPackageTests/RssdpUwpPackageTests/RssdpUwpPackageTests.csproj +++ b/src/RssdpPackageTests/RssdpUwpPackageTests/RssdpUwpPackageTests.csproj @@ -15,6 +15,6 @@ true - + \ No newline at end of file