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

AWS SimpleDB #87

Open
wants to merge 9 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ release

#dotCover
*.dotCover

#TestResults
/TestResults/*
7 changes: 7 additions & 0 deletions Extensions/src/Ncqrs.Eventing.Storage.AWS.Tests/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="AWSAccessKey" value="AKIAIRZWTSGLVNITXB3A"/>
<add key="AWSSecretKey" value="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"/>
</appSettings>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using Ncqrs.Commanding.CommandExecution.Mapping.Attributes;
using Ncqrs.Commanding;

namespace Ncqrs.Eventing.Storage.AWS.Tests.Env
{
[MapsToAggregateRootMethod(typeof(Note), "ChangeNoteText")]
public class ChangeNoteCommand : CommandBase
{
[AggregateRootId]
public Guid NoteId { get; set; }
public string NewNoteText { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using Ncqrs.Commanding;
using Ncqrs.Commanding.CommandExecution.Mapping.Attributes;

namespace Ncqrs.Eventing.Storage.AWS.Tests.Env
{
[MapsToAggregateRootConstructor(typeof(Note))]
public class CreateNoteCommand : CommandBase
{
public Guid NoteId { get; set; }
public string NoteText { get; set; }
}
}
48 changes: 48 additions & 0 deletions Extensions/src/Ncqrs.Eventing.Storage.AWS.Tests/Env/Note.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using Ncqrs.Domain;

namespace Ncqrs.Eventing.Storage.AWS.Tests.Env
{
public class Note : AggregateRootMappedByConvention
{
public string NoteText { get; private set; }


public Note(Guid noteId, string noteText)
: base(noteId)
{
if (noteText != null)
{
ApplyEvent(new NoteCreated
{
NoteText = noteText
});
}
}

public Note()
{
}

public void ChangeNoteText(string NewNoteText)
{
ApplyEvent(new NoteChanged
{
NewNoteText = NewNoteText
});

}

protected void OnNoteCreated(NoteCreated e)
{
NoteText = e.NoteText;
}

protected void OnNoteChange(NoteChanged e)
{
NoteText = e.NewNoteText;
}


}
}
12 changes: 12 additions & 0 deletions Extensions/src/Ncqrs.Eventing.Storage.AWS.Tests/Env/NoteChanged.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using Ncqrs.Eventing.Sourcing;

namespace Ncqrs.Eventing.Storage.AWS.Tests.Env
{
[Serializable]
public class NoteChanged : SourcedEvent
{
public Guid NoteId { get; set; }
public string NewNoteText { get; set; }
}
}
12 changes: 12 additions & 0 deletions Extensions/src/Ncqrs.Eventing.Storage.AWS.Tests/Env/NoteCreated.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using Ncqrs.Eventing.Sourcing;

namespace Ncqrs.Eventing.Storage.AWS.Tests.Env
{
[Serializable]
public class NoteCreated : SourcedEvent
{
Guid NoteId { get; set; }
public string NoteText { get; set; }
}
}
18 changes: 18 additions & 0 deletions Extensions/src/Ncqrs.Eventing.Storage.AWS.Tests/Env/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Ncqrs.Commanding.ServiceModel;
using Ncqrs.Commanding.CommandExecution.Mapping.Attributes;

namespace Ncqrs.Eventing.Storage.AWS.Tests.Env
{
public static class Startup
{
public static void Start()
{
NcqrsEnvironment.SetDefault<IEventStore>(new SimpleDBStore("MainTest"));
CommandService c = new CommandService();

c.RegisterExecutorsInAssembly(typeof(CreateNoteCommand).Assembly);

NcqrsEnvironment.SetDefault<ICommandService>(c);
}
}
}
71 changes: 71 additions & 0 deletions Extensions/src/Ncqrs.Eventing.Storage.AWS.Tests/MainTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ncqrs.Commanding.ServiceModel;
using Ncqrs.Eventing.Storage.AWS.Tests.Env;

namespace Ncqrs.Eventing.Storage.AWS.Tests
{
[TestClass]
public class MainTests
{
public MainTests()
{
Startup.Start();
}

[TestMethod]
public void SniffForSmoke()
{
Guid smokeID = Guid.NewGuid();
NcqrsEnvironment.Get<ICommandService>().Execute(new CreateNoteCommand
{
NoteId = smokeID,
NoteText = "Hello world"
});

NcqrsEnvironment.Get<ICommandService>().Execute(new ChangeNoteCommand
{
NoteId = smokeID,
NewNoteText = "Hello universe"
});
}

[TestMethod]
public void LoadItUp()
{
IList<Guid> ids = new List<Guid>();

for (int i = 0; i < 5; i++)
{
Guid id = Guid.NewGuid();
ids.Add(id);

NcqrsEnvironment.Get<ICommandService>().Execute(new CreateNoteCommand
{
NoteId = id,
NoteText = "Hello world " + i
});
}


foreach (Guid id in ids)
{
NcqrsEnvironment.Get<ICommandService>().Execute(new ChangeNoteCommand
{
NoteId = id,
NewNoteText = "Hello solar system"
});
}

foreach (Guid id in ids)
{
NcqrsEnvironment.Get<ICommandService>().Execute(new ChangeNoteCommand
{
NoteId = id,
NewNoteText = "Hello galaxy"
});
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{04D30F12-E5F0-4805-AEA7-F3AB3C3BED8C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Ncqrs.Eventing.Storage.AWS.Tests</RootNamespace>
<AssemblyName>Ncqrs.Eventing.Storage.AWS.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>..\..\..\lib\Release\Ncqrs.Eventing.Storage.AWS.Tests\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\lib\ThirdParty\json.net\Newtonsoft.Json.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.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Env\ChangeNoteCommand.cs" />
<Compile Include="Env\CreateNoteCommand.cs" />
<Compile Include="Env\Note.cs" />
<Compile Include="Env\NoteChanged.cs" />
<Compile Include="Env\NoteCreated.cs" />
<Compile Include="Env\Startup.cs" />
<Compile Include="MainTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Framework\src\Ncqrs\Ncqrs.csproj">
<Project>{01F84441-80D3-49B4-AB18-96894ACB2F90}</Project>
<Name>Ncqrs</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Samples\MyNotes\src\ApplicationService\ApplicationService.csproj">
<Project>{B43AEA6E-59C2-4731-91EA-40C36CEE8360}</Project>
<Name>ApplicationService</Name>
</ProjectReference>
<ProjectReference Include="..\Ncqrs.Eventing.Storage.AWS\Ncqrs.Eventing.Storage.AWS.csproj">
<Project>{D8D8A477-8018-432B-8E85-795E425D4862}</Project>
<Name>Ncqrs.Eventing.Storage.AWS</Name>
</ProjectReference>
</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>
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("Ncqrs.Eventing.Storage.AWS.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Ncqrs.Eventing.Storage.AWS.Tests")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[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("84e3fbf7-66d2-4dfe-986a-42909624936e")]

// 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")]
Loading