Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to improve build and test and removed need for nuspec (which incorrectly references Newtonsoft now) #58

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ TestResults/
*nupkg

# globs
.vs
Makefile.in
*.DS_Store
*.sln.cache
Expand Down
29 changes: 15 additions & 14 deletions Plivo.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plivo", "src\Plivo\Plivo.csproj", "{EF3352B6-54D2-4731-95B5-D07D01982713}"
# Visual Studio 15
VisualStudioVersion = 15.0.27520.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plivo", "src\Plivo\Plivo.csproj", "{EF3352B6-54D2-4731-95B5-D07D01982713}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plivo.Test", "tests\Plivo.Test\Plivo.Test.csproj", "{EDFC32D7-13A7-47F2-9E3D-8250D60B6408}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plivo.NetCore.Test", "tests_netcore\Plivo.NetCore.Test\Plivo.NetCore.Test.csproj", "{72465D60-EA64-47A8-8F6E-E44E2C99BD60}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plivo.Test", "tests\Plivo.Test\Plivo.Test.csproj", "{B8A52586-250B-4301-B9E2-7631B4DEE45E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -17,14 +16,16 @@ Global
{EF3352B6-54D2-4731-95B5-D07D01982713}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF3352B6-54D2-4731-95B5-D07D01982713}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF3352B6-54D2-4731-95B5-D07D01982713}.Release|Any CPU.Build.0 = Release|Any CPU
{EDFC32D7-13A7-47F2-9E3D-8250D60B6408}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDFC32D7-13A7-47F2-9E3D-8250D60B6408}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDFC32D7-13A7-47F2-9E3D-8250D60B6408}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDFC32D7-13A7-47F2-9E3D-8250D60B6408}.Release|Any CPU.Build.0 = Release|Any CPU
{72465D60-EA64-47A8-8F6E-E44E2C99BD60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72465D60-EA64-47A8-8F6E-E44E2C99BD60}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72465D60-EA64-47A8-8F6E-E44E2C99BD60}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72465D60-EA64-47A8-8F6E-E44E2C99BD60}.Release|Any CPU.Build.0 = Release|Any CPU
{B8A52586-250B-4301-B9E2-7631B4DEE45E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8A52586-250B-4301-B9E2-7631B4DEE45E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8A52586-250B-4301-B9E2-7631B4DEE45E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8A52586-250B-4301-B9E2-7631B4DEE45E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9357C9EF-88DD-4221-9801-0B6BA94E2569}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
description = A .NET SDK to make voice calls & send SMS using Plivo and to generate Plivo XML
Expand Down
56 changes: 55 additions & 1 deletion src/Plivo/Plivo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,74 @@
<Summary>A .NET SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML</Summary>
<Title>Plivo</Title>
<Description>A .NET SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML</Description>
<PackageReleaseNotes>* 4.1.0 Added Address and Identity resources. Fixes unhandled NullReferenceException.
* 4.0.0 Supports v2 signature validation. Targets .NET Standard 1.3
* 4.0.0-beta2 Fix Pricing API interface
* 4.0.0-beta1 Support .NET Core 1.0+ and .NET Framework 4.5+
* 3.0.7 Re-release
* 3.0.6 Added addition verify signature function
* 3.0.5 Added support for RestSharp 105.2.3
* 3.0.4 Added digitsMatchBLeg parameter to Dial XML.
* 3.0.3 Fixed sorting in Verify function
* 3.0.2 Added answer_time and initiation_time to CDR model.
* 3.0.1 Added beep attribute to Wait XML.
* 3.0.0 Updated RestSharpSigned
* 2.0.2 Added Request API function, stop_speak_member function in Conference API and abstracted all API responses to a parent class PlivoResponse.
* 2.0.1 Added modify_number function.
* 2.0.0 Update and separate bundling of RestSharp client and add RestSharpSigned as nuget package dependency. Signed version enables it to work with modern as well as older projects that still require strongname binaries.
* 1.3.7 Make Verify Signature function public
* 1.3.5 PhoneNumber API
* 1.3.2 Added old_auth_token and auth_token fields to SubAccount response
* 1.3.1 Added log attribute in GetDigits to handle sensitive DTMF info
* 1.3.0 Added Delete Recording API
* 1.2.9 Added minSilence attribute in Wait, async attribute in DTMF, NuGet Update -selfrelayDTMF attribute in Conference, stop_speak() method and invalid_numbers in Call Response and added get_account, get_recordings, get_recording and get_recording_by_call_uuid methods
* 1.2.8 Fixed issue with returning of nested XML object.
* 1.2.7 Added 'recordWhenAlone' attribute in Conference XML.
* 1.2.6 Fixed available number group for renting numbers.
* 1.2.5 Fix issues with packaging.
* 1.2.3 Allow optional parameters on various APIs.
* 1.2.2 Minor change. Fix for speak api method.
* 1.2.0 Additional APIs coverage: incoming carrier and pricing. support for unicode.
* 1.1.7 Minor change. Updated attributes for Conference and Record Elements.
* 1.1.6 Minor change. Updated attributes for GetDigits Element.
* 1.1.5 Minor change. Updated attributes for Conference Element.
* 1.1.4 Minor change. Updated attributes for Record Element.
* 1.1.3 Minor fix for attribute error.
* 1.1.2 Added attribute to XML element Wait.
* 1.1.1 Added method for making bulk calls with sip headers for each.
* 1.1.0 Multilingual speak support html entities. Added the new message APIs. Also updated various model attributes to handle json response.
* 1.0.3 Minor fix to deal with GET request on few resources.
* 1.0.2 Minor fix for PlivoElement.AddWait method.
* 1.0.1 Minor fix for Number API calls.
* 1.0 Supports making Plivo APIs calls and generation of Plivo XML.</PackageReleaseNotes>
<PackageLicenseUrl>https://github.com/plivo/plivo-dotnet/blob/master/LICENSE.txt</PackageLicenseUrl>
<PackageProjectUrl>http://github.com/plivo/plivo-dotnet</PackageProjectUrl>
<Version>4.1.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Company>Plivo, Inc</Company>
<RepositoryUrl>https://github.com/plivo/plivo-dotnet.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Plivo REST voice SMS telephony API XML</PackageTags>
<Copyright>Copyright (c) 2018 Plivo, Inc.</Copyright>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<NoStdLib>false</NoStdLib>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoStdLib>false</NoStdLib>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="NuGet.Build.Packaging" Version="0.1.276" />
<!--<PackageReference Include="NuGet.Build.Packaging" Version="0.2.2" />-->
</ItemGroup>

<ItemGroup>
<Folder Include="Resource\Address\" />
<Folder Include="Resource\Identity\" />
</ItemGroup>

</Project>
19 changes: 9 additions & 10 deletions tests/Plivo.Test/BaseTestCase.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
using System;
using System.Collections.Generic;
using System.IO;
using System;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using Xunit;
using Plivo.Http;
using Plivo.Utilities;

namespace Plivo.Test
namespace Plivo.NetCore.Test
{
public class BaseTestCase
{
public PlivoApi Api;
public TestClient TestClient;

public string SOURCE_DIR = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"/../../";
public string SOURCE_DIR = AppContext.BaseDirectory + @"/../../";

public BaseTestCase()
{
Expand All @@ -37,20 +35,21 @@ public void AssertRequest(PlivoRequest request)

public void CompareRequests(PlivoRequest a, PlivoRequest b)
{
Assert.AreEqual(a.Method, b.Method);
Assert.AreEqual(a.Uri, b.Uri);
Assert.Equal(a.Method, b.Method);
Assert.Equal(a.Uri, b.Uri);

// Console.WriteLine(string.Join(",", a.Data.Select(kvp => kvp.Key + ":" + kvp.Value).ToList()));
// Console.WriteLine(string.Join(",", b.Data.Select(kvp => kvp.Key + ":" + kvp.Value).ToList()));
//
// Console.WriteLine(JsonConvert.SerializeObject(a.Data));
// Console.WriteLine(JsonConvert.SerializeObject(b.Data));
Assert.IsEmpty(

Assert.Empty(
ComparisonUtilities.CompareRawObjects(
JObject.Parse(JsonConvert.SerializeObject(a.Data)),
JObject.Parse(JsonConvert.SerializeObject(b.Data))).ToString()
);
Assert.IsEmpty(
Assert.Empty(
ComparisonUtilities.CompareRawObjects(
JObject.Parse(JsonConvert.SerializeObject(b.Data)),
JObject.Parse(JsonConvert.SerializeObject(a.Data))).ToString()
Expand Down
122 changes: 12 additions & 110 deletions tests/Plivo.Test/Plivo.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,118 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EDFC32D7-13A7-47F2-9E3D-8250D60B6408}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Plivo.Test</RootNamespace>
<AssemblyName>Plivo.Test</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworks>netcoreapp1.1;net462</TargetFrameworks>
<IsPackable>false</IsPackable>
<ReleaseVersion>4.1.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="BaseTestCase.cs" />
<Compile Include="Resources\TestAccount.cs" />
<Compile Include="Resources\TestCall.cs" />
<Compile Include="Resources\TestConference.cs" />
<Compile Include="Resources\TestEndpoint.cs" />
<Compile Include="Resources\TestExceptions.cs" />
<Compile Include="Resources\TestMessage.cs" />
<Compile Include="Resources\TestNumber.cs" />
<Compile Include="Resources\TestPhoneNumber.cs" />
<Compile Include="Resources\TestPricing.cs" />
<Compile Include="Resources\TestRecording.cs" />
<Compile Include="Resources\TestSubaccount.cs" />
<Compile Include="TestClient.cs" />
<Compile Include="XML\TestXML.cs" />
<Compile Include="TestSignature.cs" />
<Compile Include="Resources\TestAddress.cs" />
<Compile Include="Resources\TestIdentity.cs" />
</ItemGroup>

<ItemGroup>
<Content Include="Mocks\accountGetResponse.json" />
<Content Include="Mocks\accountModifyResponse.json" />
<Content Include="Mocks\applicationCreateResponse.json" />
<Content Include="Mocks\applicationGetResponse.json" />
<Content Include="Mocks\applicationListResponse.json" />
<Content Include="Mocks\applicationModifyResponse.json" />
<Content Include="Mocks\callCreateResponse.json" />
<Content Include="Mocks\callGetResponse.json" />
<Content Include="Mocks\callListResponse.json" />
<Content Include="Mocks\callUpdateResponse.json" />
<Content Include="Mocks\conferenceDeleteAllResponse.json" />
<Content Include="Mocks\conferenceDeleteResponse.json" />
<Content Include="Mocks\conferenceGetResponse.json" />
<Content Include="Mocks\conferenceListResponse.json" />
<Content Include="Mocks\conferenceMemberDeafCreateResponse.json" />
<Content Include="Mocks\conferenceMemberDeleteResponse.json" />
<Content Include="Mocks\conferenceMemberKickCreateResponse.json" />
<Content Include="Mocks\conferenceMemberMuteCreateResponse.json" />
<Content Include="Mocks\conferenceMemberPlayCreateResponse.json" />
<Content Include="Mocks\conferenceMemberPlayDeleteResponse.json" />
<Content Include="Mocks\conferenceMemberSpeakCreateResponse.json" />
<Content Include="Mocks\conferenceMemberSpeakDeleteResponse.json" />
<Content Include="Mocks\conferenceRecordCreateResponse.json" />
<Content Include="Mocks\endpointCreateResponse.json" />
<Content Include="Mocks\endpointGetResponse.json" />
<Content Include="Mocks\endpointListResponse.json" />
<Content Include="Mocks\endpointUpdateResponse.json" />
<Content Include="Mocks\liveCallDtmfCreateResponse.json" />
<Content Include="Mocks\liveCallGetResponse.json" />
<Content Include="Mocks\liveCallListGetResponse.json" />
<Content Include="Mocks\liveCallPlayCreateResponse.json" />
<Content Include="Mocks\liveCallRecordCreateResponse.json" />
<Content Include="Mocks\liveCallSpeakCreateResponse.json" />
<Content Include="Mocks\liveCallSpeakDeleteResponse.json" />
<Content Include="Mocks\messageGetResponse.json" />
<Content Include="Mocks\messageListResponse.json" />
<Content Include="Mocks\messageSendResponse.json" />
<Content Include="Mocks\numberCreateResponse.json" />
<Content Include="Mocks\numberGetResponse.json" />
<Content Include="Mocks\numberListResponse.json" />
<Content Include="Mocks\numberUpdateResponse.json" />
<Content Include="Mocks\phoneNumberCreateResponse.json" />
<Content Include="Mocks\phoneNumberListResponse.json" />
<Content Include="Mocks\pricingGetResponse.json" />
<Content Include="Mocks\recordingGetResponse.json" />
<Content Include="Mocks\recordingListResponse.json" />
<Content Include="Mocks\subaccountCreateResponse.json" />
<Content Include="Mocks\subaccountGetResponse.json" />
<Content Include="Mocks\subaccountListResponse.json" />
<Content Include="Mocks\subaccountModifyResponse.json" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="System.Net.Primitives" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Plivo\Plivo.csproj">
<Project>{EF3352B6-54D2-4731-95B5-D07D01982713}</Project>
<Name>Plivo</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Plivo\Plivo.csproj" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

</Project>
21 changes: 12 additions & 9 deletions tests/Plivo.Test/Resources/TestAccount.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using System.Linq;
using Newtonsoft.Json;
using Xunit;
using Plivo.Authentication;
using Plivo.Http;
using Plivo.Resource;
using Plivo.Resource.Account;
using Plivo.Utilities;

namespace Plivo.Test.Resources
namespace Plivo.NetCore.Test.Resources
{
[TestFixture]
public class TestAccount : BaseTestCase
{
[Test]
[Fact]
public void TestAccountDetails()
{
var request =
Expand All @@ -21,17 +24,17 @@ public void TestAccountDetails()

var response =
System.IO.File.ReadAllText(
SOURCE_DIR + @"Mocks/accountGetResponse.json"
SOURCE_DIR + @"../Mocks/accountGetResponse.json"
);
Setup<Account>(
200,
response
);
Assert.IsEmpty(ComparisonUtilities.Compare(response, Api.Account.Get()));
Assert.Empty(ComparisonUtilities.Compare(response, Api.Account.Get()));
AssertRequest(request);
}

[Test]
[Fact]
public void TestAccountModifyResponse()
{
var data = new Dictionary<string, object>()
Expand All @@ -48,13 +51,13 @@ public void TestAccountModifyResponse()

var response =
System.IO.File.ReadAllText(
SOURCE_DIR + @"Mocks/accountModifyResponse.json"
SOURCE_DIR + @"../Mocks/accountModifyResponse.json"
);
Setup<UpdateResponse<Account>>(
202,
response
);
Assert.IsEmpty(ComparisonUtilities.Compare(response, Api.Account.Update("name name name", "delhi")));
Assert.Empty(ComparisonUtilities.Compare(response, Api.Account.Update("name name name", "delhi")));

CompareRequests(request, ((TestClient) Api.Client._client).Request);
}
Expand Down
Loading