Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added feature to configure username factory and default username
- Loading branch information
Bilal Fazlani
committed
May 21, 2016
1 parent
67ac7ab
commit c77ce49
Showing
15 changed files
with
185 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,3 +155,4 @@ $RECYCLE.BIN/ | |
|
||
# Mac desktop service store files | ||
.DS_Store | ||
/.vs/config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="EntityFramework" version="6.1.1" targetFramework="net45" /> | ||
<package id="EntityFramework" version="6.1.3" targetFramework="net45" /> | ||
<package id="EntityFramework.MappingAPI" version="6.1.0.9" targetFramework="net45" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
TrackerEnabledDbContext.Identity.IntegrationTests/UsernameConfigurationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using TrackerEnabledDbContext.Common.Testing; | ||
using TrackerEnabledDbContext.Common.Testing.Extensions; | ||
using TrackerEnabledDbContext.Common.Testing.Models; | ||
|
||
namespace TrackerEnabledDbContext.Identity.IntegrationTests | ||
{ | ||
[TestClass] | ||
public class UsernameConfigurationTests : PersistanceTests<TestTrackerIdentityContext> | ||
{ | ||
[TestMethod] | ||
public void Can_use_username_factory() | ||
{ | ||
Db.ConfigureUsername(()=> "bilal"); | ||
|
||
NormalModel model = | ||
GetObjectFactory<NormalModel>().Create(); | ||
Db.NormalModels.Add(model); | ||
Db.SaveChanges(); | ||
model.Id.AssertIsNotZero(); | ||
|
||
model.AssertAuditForAddition(Db, model.Id, | ||
"bilal", | ||
x => x.Id, | ||
x => x.Description | ||
); | ||
} | ||
|
||
[TestMethod] | ||
public void Can_username_factory_override_default_username() | ||
{ | ||
Db.ConfigureUsername(() => "bilal"); | ||
Db.ConfigureUsername("rahul"); | ||
|
||
NormalModel model = | ||
GetObjectFactory<NormalModel>().Create(); | ||
Db.NormalModels.Add(model); | ||
Db.SaveChanges(); | ||
model.Id.AssertIsNotZero(); | ||
|
||
model.AssertAuditForAddition(Db, model.Id, | ||
"bilal", | ||
x => x.Id, | ||
x => x.Description | ||
); | ||
} | ||
|
||
[TestMethod] | ||
public void Can_use_default_username() | ||
{ | ||
Db.ConfigureUsername("rahul"); | ||
|
||
NormalModel model = | ||
GetObjectFactory<NormalModel>().Create(); | ||
Db.NormalModels.Add(model); | ||
Db.SaveChanges(); | ||
model.Id.AssertIsNotZero(); | ||
|
||
model.AssertAuditForAddition(Db, model.Id, | ||
"rahul", | ||
x => x.Id, | ||
x => x.Description | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
TrackerEnabledDbContext.IntegrationTests/UsernameConfigurationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using TrackerEnabledDbContext.Common.Testing; | ||
using TrackerEnabledDbContext.Common.Testing.Extensions; | ||
using TrackerEnabledDbContext.Common.Testing.Models; | ||
|
||
namespace TrackerEnabledDbContext.IntegrationTests | ||
{ | ||
[TestClass] | ||
public class UsernameConfigurationTests : PersistanceTests<TestTrackerContext> | ||
{ | ||
[TestMethod] | ||
public void Can_use_username_factory() | ||
{ | ||
Db.ConfigureUsername(() => "bilal"); | ||
|
||
NormalModel model = | ||
GetObjectFactory<NormalModel>().Create(); | ||
Db.NormalModels.Add(model); | ||
Db.SaveChanges(); | ||
model.Id.AssertIsNotZero(); | ||
|
||
model.AssertAuditForAddition(Db, model.Id, | ||
"bilal", | ||
x => x.Id, | ||
x => x.Description | ||
); | ||
} | ||
|
||
[TestMethod] | ||
public void Can_username_factory_override_default_username() | ||
{ | ||
Db.ConfigureUsername(() => "bilal"); | ||
Db.ConfigureUsername("rahul"); | ||
|
||
NormalModel model = | ||
GetObjectFactory<NormalModel>().Create(); | ||
Db.NormalModels.Add(model); | ||
Db.SaveChanges(); | ||
model.Id.AssertIsNotZero(); | ||
|
||
model.AssertAuditForAddition(Db, model.Id, | ||
"bilal", | ||
x => x.Id, | ||
x => x.Description | ||
); | ||
} | ||
|
||
[TestMethod] | ||
public void Can_use_default_username() | ||
{ | ||
Db.ConfigureUsername("rahul"); | ||
|
||
NormalModel model = | ||
GetObjectFactory<NormalModel>().Create(); | ||
Db.NormalModels.Add(model); | ||
Db.SaveChanges(); | ||
model.Id.AssertIsNotZero(); | ||
|
||
model.AssertAuditForAddition(Db, model.Id, | ||
"rahul", | ||
x => x.Id, | ||
x => x.Description | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters