Skip to content

Commit

Permalink
version 1.2.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
a-legotin committed Dec 10, 2016
2 parents a294972 + 861493a commit d8a981a
Show file tree
Hide file tree
Showing 101 changed files with 1,812 additions and 670 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: csharp
solution: InstagramAPI.sln
solution: InstaSharper.sln
dotnet: 1.0.0-preview2-003121
sudo: required
os: linux
Expand All @@ -10,9 +10,9 @@ script:
- dotnet --info
# Run dotnet new
- dotnet restore
- cd InstagramAPI
- cd InstaSharper
- dotnet --verbose build
- cd ../InstagramAPI.Tests
- cd ../InstaSharper.Tests
- dotnet --verbose build
- dotnet --verbose test
- dotnet --verbose test -parallel none

7 changes: 7 additions & 0 deletions InstaSharper.Examples/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
63 changes: 63 additions & 0 deletions InstaSharper.Examples/InstaSharper.Examples.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{620D3DB5-5636-4A54-A7D7-600C6518C20E}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>InstaSharper.Examples</RootNamespace>
<AssemblyName>InstaSharper.Examples</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="InstaSharper">
<HintPath>..\InstaSharper\bin\Debug\net452\InstaSharper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="InstaSharperExamples.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<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>
22 changes: 22 additions & 0 deletions InstaSharper.Examples/InstaSharper.Examples.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstaSharper.Examples", "InstaSharper.Examples.csproj", "{620D3DB5-5636-4A54-A7D7-600C6518C20E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{620D3DB5-5636-4A54-A7D7-600C6518C20E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{620D3DB5-5636-4A54-A7D7-600C6518C20E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{620D3DB5-5636-4A54-A7D7-600C6518C20E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{620D3DB5-5636-4A54-A7D7-600C6518C20E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
64 changes: 64 additions & 0 deletions InstaSharper.Examples/InstaSharperExamples.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Linq;
using InstaSharper.API;
using InstaSharper.API.Builder;
using InstaSharper.Classes;

namespace InstaSharper.Examples
{
internal class InstaSharperExamples
{
private static IInstaApi _instaApi;

private static void Main(string[] args)
{
// create user session data and provide login details
var userSession = new UserSessionData
{
UserName = "username",
Password = "password"
};
// create new InstaApi instance using Builder
_instaApi = new InstaApiBuilder()
.SetUser(userSession)
.Build();
// login
var logInResult = _instaApi.Login();
if (!logInResult.Succeeded) { Console.WriteLine($"Unable to login: {logInResult.Message}"); }
else
{
// get currently logged in user
var currentUser = _instaApi.GetCurrentUser().Value;
Console.WriteLine($"Logged in: username - {currentUser.UserName}, full name - {currentUser.FullName}");
// get followers
var followers = _instaApi.GetUserFollowersAsync(currentUser.UserName, 5).Result.Value;
Console.WriteLine($"Count of followers [{currentUser.UserName}]:{followers.Count}");
// get user's media
var currentUserMedia = _instaApi.GetUserMedia(currentUser.UserName, 5);
if (currentUserMedia.Succeeded)
{
Console.WriteLine($"Media count [{currentUser.UserName}]: {currentUserMedia.Value.Count}");
foreach (var media in currentUserMedia.Value) Console.WriteLine($"Media [{currentUser.UserName}]: {media.Caption.Text}, {media.Code}, likes: {media.LikesCount}, image link: {media.Images.LastOrDefault()?.Url}");
}

//get user feed, first 5 pages
var userFeed = _instaApi.GetUserFeed(5);
if (userFeed.Succeeded)
{
Console.WriteLine($"Feed items (in {userFeed.Value.Pages} pages) [{currentUser.UserName}]: {userFeed.Value.Items.Count}");
foreach (var media in userFeed.Value.Items) Console.WriteLine($"Feed item - code:{media.Code}, likes: {media.LikesCount}");
}
// get tag feed, first 5 pages
var tagFeed = _instaApi.GetTagFeed("gm", 5);
if (userFeed.Succeeded)
{
Console.WriteLine($"Tag feed items (in {tagFeed.Value.Pages} pages) [{currentUser.UserName}]: {tagFeed.Value.Count}");
foreach (var media in tagFeed.Value) Console.WriteLine($"Tag feed item - code: {media.Code}, likes: {media.LikesCount}");
}
var logoutResult = _instaApi.Logout();
if (logoutResult.Value) Console.WriteLine("Logout succeed");
}
Console.ReadKey();
}
}
}
39 changes: 39 additions & 0 deletions InstaSharper.Examples/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Reflection;
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("InstaSharper.Examples")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InstaSharper.Examples")]
[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("620d3db5-5636-4a54-a7d7-600c6518c20e")]

// 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")]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>dbe6fbb7-cde7-4cdf-ab08-989a43cc4d46</ProjectGuid>
<RootNamespace>InstagramAPI.Tests</RootNamespace>
<RootNamespace>InstaSharper.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using System.Reflection;
using System.Runtime.InteropServices;
using Xunit;

// 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: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InstagramApi.Tests")]
[assembly: AssemblyProduct("InstaSharper.Tests")]
[assembly: AssemblyTrademark("")]
[assembly: CollectionBehavior(DisableTestParallelization = true)]


// 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using InstagramAPI.API.Builder;
using InstagramAPI.Tests.Utils;
using InstaSharper.API.Builder;
using InstaSharper.Tests.Utils;
using Xunit;

namespace InstagramAPI.Tests.Tests
namespace InstaSharper.Tests.Tests
{
[Collection("InstaSharper Tests")]
public class ApiInstanceBuilderTest
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
using System;
using InstagramAPI.Classes;
using InstagramAPI.Tests.Utils;
using InstaSharper.Classes;
using InstaSharper.Tests.Utils;
using Xunit;
using Xunit.Abstractions;

namespace InstagramAPI.Tests.Tests
namespace InstaSharper.Tests.Tests
{
public class LoginTest
[Collection("InstaSharper Tests")]
public class AuthTest
{
public LoginTest(ITestOutputHelper output)
public AuthTest(ITestOutputHelper output)
{
this.output = output;
_output = output;
}

private readonly ITestOutputHelper output;
private readonly ITestOutputHelper _output;

[Fact]
public async void UserLoginFailTest()
{
//arrange
var username = "alex_codegarage";
var password = "boombaby!";
var apiInstance =
TestHelpers.GetDefaultInstaApiInstance(new UserCredentials
TestHelpers.GetDefaultInstaApiInstance(new UserSessionData
{
UserName = username,
Password = password
});
output.WriteLine("Got API instance");
//act
_output.WriteLine("Got API instance");
var loginResult = await apiInstance.LoginAsync();
//assert
Assert.False(loginResult.Succeeded);
Assert.False(apiInstance.IsUserAuthenticated);
}

[Fact]
public async void UserLoginSuccessTest()
{
//arrange
var username = "alex_codegarage";
var password = Environment.GetEnvironmentVariable("instaapiuserpassword");
var apiInstance =
TestHelpers.GetDefaultInstaApiInstance(new UserCredentials
{
UserName = username,
Password = password
});
output.WriteLine("Got API instance");
//act
var apiInstance = TestHelpers.GetDefaultInstaApiInstance(new UserSessionData
{
UserName = username,
Password = password
});
Assert.False(apiInstance.IsUserAuthenticated);

var loginResult = await apiInstance.LoginAsync();
//assert
Assert.True(loginResult.Succeeded);
Assert.True(apiInstance.IsUserAuthenticated);
}
Expand Down
40 changes: 40 additions & 0 deletions InstaSharper.Tests/Tests/DiscoverTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using InstaSharper.Classes;
using InstaSharper.Tests.Utils;
using Xunit;
using Xunit.Abstractions;

namespace InstaSharper.Tests.Tests
{
[Collection("InstaSharper Tests")]
public class DiscoverTest
{
public DiscoverTest(ITestOutputHelper output)
{
_output = output;
}

private readonly ITestOutputHelper _output;
private readonly string _username = "alex_codegarage";
private readonly string _password = Environment.GetEnvironmentVariable("instaapiuserpassword");

[Fact]
public async void ExploreTest()
{
//arrange
var apiInstance =
TestHelpers.GetDefaultInstaApiInstance(new UserSessionData
{
UserName = _username,
Password = _password
});
//act
if (!TestHelpers.Login(apiInstance, _output)) return;
var result = await apiInstance.GetExploreFeedAsync(0);
var exploreGeed = result.Value;
//assert
Assert.True(result.Succeeded);
Assert.NotNull(exploreGeed);
}
}
}
Loading

0 comments on commit d8a981a

Please sign in to comment.