This file contains hidden or 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
| func(s *Session) DropDatabase(db string) error { | |
| if(s.session != nil) { | |
| return s.session.DB(db).DropDatabase() | |
| } | |
| return nil | |
| } |
This file contains hidden or 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
| defer func() { | |
| session.DropDatabase(dbName) | |
| session.Close() | |
| }() |
This file contains hidden or 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
| using System.Text; | |
| using System; | |
| namespace BigLegacyApplication | |
| { | |
| internal class ReportGenerator | |
| { | |
| public ReportGenerator() | |
| { | |
| } |
This file contains hidden or 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
| internal interface IUserService | |
| { | |
| User GetUser(int userId); | |
| } | |
| internal interface IResultService | |
| { | |
| string[] GetUserResults(int userId); | |
| } |
This file contains hidden or 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
| private readonly IUserService _userService; | |
| public IUserService userService { | |
| get { | |
| if(_userService == null) | |
| _userService = new UserService(); | |
| return _userService; | |
| } | |
| set { _userService = value; } | |
| } |
This file contains hidden or 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
| var mockUserService = new MockUserService(); | |
| var mockResultService = new MockResultService(); | |
| var resultGenerator = new ResultGenerator(); | |
| resultGenerator.userService = mockUserService; | |
| resultGenerator.mockResultService = mockResultService; |
This file contains hidden or 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
| using System.Text; | |
| using System; | |
| namespace BigLegacyApplication | |
| { | |
| internal class ReportGenerator | |
| { | |
| public ReportGenerator(){} | |
| internal string GetUserReport(int userId) |
This file contains hidden or 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
| public class TesableResultGenerator : ResultGenerator | |
| { | |
| private IUserService _userService; | |
| private IResultService _resultService; | |
| private DateTime _dateTime; | |
| public TestableResultGenerator(IUserService userService, IResultService resultService, DateTime dateTime) | |
| : base() { | |
| _userService = userService; | |
| _resultService = resultService; |
This file contains hidden or 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
| var mockUserService = new MockUserService(); | |
| var mockResultService = new MockResultService(); | |
| var testTime = new DateTime(1,1,2000); | |
| var resultGenerator = new ResultGenerator(mockUserService, mockResultService, testTime); |
This file contains hidden or 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
| package root | |
| type Hash interface { | |
| Generate(s string) (string, error) | |
| Compare(hash string, s string) error | |
| } |