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 _ = require('lodash'), | |
| ActivityController = require('../../../controllers/activity.controller'), | |
| FakeDatabase = [ | |
| {userId: '123', Name: 'First Activity', Records: [{Date: new Date(2014, 1, 1)}]}, | |
| {userId: '123', Name: 'Second Activity', Records: [{Date: new Date(2014, 2, 1)}]}]; | |
| require('underscore-query')(_); | |
| ActivityController.Activity.find = function(findObject, callback){ | |
| var activities = _.query(FakeDatabase, findObject); |
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
| describe('User Service...', function(){ | |
| var userService, | |
| customerService, | |
| scope; | |
| beforeEach(inject(function(testHelper){ | |
| userService = testHelper.setUpMocksWithSpies('UserService'); | |
| customerService = testHelper.setUpMocksWithSpies('CustomerService'); | |
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
| $scope.isBalancePositive = function(){ | |
| if($scope.balance > 0){ | |
| return true; | |
| } | |
| } |
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 DataProfiler : IProfiler | |
| { | |
| public DataProfiler() | |
| { | |
| Enabled = true; | |
| } | |
| public bool Enabled { get; set; } | |
| public void Update(PetaPocoSqlInfo info) |
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 DataProfiler : ISqlProfiler | |
| { | |
| public DataProfiler() | |
| { | |
| Enabled = true; | |
| } | |
| public bool Enabled { get; set; } | |
| public void Update(PetaPocoSqlInfo info) |
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
| [GlimpsePlugin] | |
| public class PetaPocoGlimpsePlugin : IGlimpsePlugin | |
| { | |
| public object GetData(HttpContextBase context) | |
| { | |
| if (context.Items[DataProfiler.PetaKey] == null) | |
| return new List<object[]> { new[] { "Log" }, new[] { "No database requests or database logging not switched on (Compilation debug='true' or ForceLogging='true' on | |
| PetaPoco.DatabaseWithLogging)", "warn" } }; | |
| var sqls = new List<object[]> {new[] {"#", "Time(ms)", "Sql", "Parameters"}}; |
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 SqlInfo | |
| { | |
| public double Time { get; set; } | |
| public string FormattedSql { get; set; } | |
| public string Sql { get; set; } | |
| public IDataParameterCollection Parameters { get; set; } | |
| } |
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 interface ISqlProfiler | |
| { | |
| bool Enabled { get;} | |
| void Update(PetaPocoSqlInfo info); | |
| } |
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
| CREATE TYPE [dbo].[MyRecords] AS TABLE( | |
| [Id] [int] NOT NULL, | |
| [ModuleId] [int] NOT NULL, | |
| [Code] [nvarchar](20) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, | |
| PRIMARY KEY CLUSTERED | |
| ( | |
| [Id] ASC, | |
| [ModuleId] ASC, | |
| [Code] ASC | |
| )WITH (IGNORE_DUP_KEY = OFF) |
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 returnCode = Database.ExecuteScalar<int>( | |
| "exec GetData @userId, @date", | |
| new {userId = userId, @date = DateTime.Now}); |
OlderNewer