Skip to content

Commit

Permalink
Added deserialization and test project
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolavn committed Jun 21, 2016
1 parent 1fb0d05 commit cf51c0f
Show file tree
Hide file tree
Showing 15 changed files with 346 additions and 24 deletions.
47 changes: 47 additions & 0 deletions Web Services And Cloud/MovieInfoApp/MovieInfo.Tests/ActorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MovieInfo.Tests
{
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MovieInfoApp;
[TestClass]
public class ActorTests
{
//In Game of Thrones Nell Tiger Free plays Myrcella Baratheon, write a test to verify the following;

[TestMethod]
public void ActorIsNotInSeason6Episode1()
{
var actorInfo = MovieDb.GetActorInfoByName("Nell Tiger Free");
var credits = MovieDb.GetTVCreditsByActorId(actorInfo.Id);
var creditsId = credits.FirstOrDefault().CreditsId;
var seriesInfo = MovieDb.GetTVSeriesDetailsByCreditsId(creditsId);

Assert.IsFalse(seriesInfo.Episodes.Any(e => e.Season == 6 && e.EpisodeNumber == 1));
}

[TestMethod]
public void ActorIsInSeason5Episode1AsMainCastMemberButNotAsGuest()
{
var actorInfo = MovieDb.GetActorInfoByName("Nell Tiger Free");
var credits = MovieDb.GetTVCreditsByActorId(actorInfo.Id);
var creditsId = credits.FirstOrDefault().CreditsId;
var seriesInfo = MovieDb.GetTVSeriesDetailsByCreditsId(creditsId);

Assert.IsTrue(seriesInfo.Seasons.Any(s => s.SeasonNumber == 5));
Assert.IsFalse(seriesInfo.Episodes.Any(e => e.Season == 5 && e.EpisodeNumber == 1));
}

[TestMethod]
public void ActorIsInSeason5Episode2AsMainCastMemberAndAsGuest()
{
var actorInfo = MovieDb.GetActorInfoByName("Nell Tiger Free");
var credits = MovieDb.GetTVCreditsByActorId(actorInfo.Id);
var creditsId = credits.FirstOrDefault().CreditsId;
var seriesInfo = MovieDb.GetTVSeriesDetailsByCreditsId(creditsId);

Assert.IsTrue(seriesInfo.Seasons.Any(s => s.SeasonNumber == 5));
Assert.IsTrue(seriesInfo.Episodes.Any(e => e.Season == 5 && e.EpisodeNumber == 2));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F2893F91-626C-42E4-940E-4D19D8D11BA4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MovieInfo.Tests</RootNamespace>
<AssemblyName>MovieInfo.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="ActorTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MovieInfoApp\MovieInfoApp.csproj">
<Project>{39eda17e-8b18-452a-86af-a237168e3847}</Project>
<Name>MovieInfoApp</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MovieInfo.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MovieInfo.Tests")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f2893f91-626c-42e4-940e-4d19d8d11ba4")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
6 changes: 6 additions & 0 deletions Web Services And Cloud/MovieInfoApp/MovieInfoApp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MovieInfoApp", "MovieInfoApp\MovieInfoApp.csproj", "{39EDA17E-8B18-452A-86AF-A237168E3847}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MovieInfo.Tests", "MovieInfo.Tests\MovieInfo.Tests.csproj", "{F2893F91-626C-42E4-940E-4D19D8D11BA4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{39EDA17E-8B18-452A-86AF-A237168E3847}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39EDA17E-8B18-452A-86AF-A237168E3847}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39EDA17E-8B18-452A-86AF-A237168E3847}.Release|Any CPU.Build.0 = Release|Any CPU
{F2893F91-626C-42E4-940E-4D19D8D11BA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2893F91-626C-42E4-940E-4D19D8D11BA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2893F91-626C-42E4-940E-4D19D8D11BA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2893F91-626C-42E4-940E-4D19D8D11BA4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
namespace MovieInfoApp.Models
{
//using Newtonsoft.Json;
using Newtonsoft.Json;

class ActorModel
public class ActorModel
{
//[JsonProperty("id")]
[JsonProperty("id")]
public int Id { get; set; }

[JsonProperty("name")]
public string Name { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace MovieInfoApp.Models
{
using Newtonsoft.Json;
using System.Collections.Generic;

public class ActorSearchResults
{
[JsonProperty("results")]
public List<ActorModel> Results { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
namespace MovieInfoApp.Models
{
//using Newtonsoft.Json;
using Newtonsoft.Json;

class CreditsModel
public class CreditsModel
{
//[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("credit_id")]
public string CreditsId { get; set; }

[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("episode_count")]
public int EpisodeCount { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace MovieInfoApp.Models
{
using System.Collections.Generic;
using Newtonsoft.Json;

public class CreditsSearchResults
{
[JsonProperty("cast")]
public List<CreditsModel> Credits { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
namespace MovieInfoApp.Models
{
//using Newtonsoft.Json;
using Newtonsoft.Json;

class EpisodeModel
public class EpisodeModel
{
//[JsonProperty("episode_number")]
[JsonProperty("episode_number")]
public int EpisodeNumber { get; set; }

//[JsonProperty("season")]
[JsonProperty("season_number")]
public int Season { get; set; }

[JsonProperty("name")]
public string EpisodeName { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace MovieInfoApp.Models
{
using Newtonsoft.Json;

public class SeasonModel
{
[JsonProperty("season_number")]
public int SeasonNumber { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace MovieInfoApp.Models
{
using System.Collections.Generic;

using Newtonsoft.Json;

public class SeriesInfo
{
[JsonProperty("episodes")]
public List<EpisodeModel> Episodes { get; set; }

[JsonProperty("seasons")]
public List<SeasonModel> Seasons { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace MovieInfoApp.Models
{
using Newtonsoft.Json;

public class SeriesSearchResults
{
[JsonProperty("media")]
public SeriesInfo SeriesInfo { get; set; }
}
}
Loading

0 comments on commit cf51c0f

Please sign in to comment.